0

How to enter/insert value into object of list class(STL) from user in c++

I have learn the basic of c++

20th Apr 2020, 5:09 PM
Amit singh
Amit singh - avatar
7 Answers
0
In this case list has initialised,my question was that to insert data from user If possible plz reply as soon as possible Thanks
20th Apr 2020, 5:40 PM
Amit singh
Amit singh - avatar
0
You mean in this manner!! #include <iostream> using namespace std; #include<stdio.h> #include<list> #include<iterator> int main() { list <int> l; int i=0; int n; while(i!=3) { cout<<"Enter number\n"; cin>>n; l.push_front(n); i++; } l.push_front(50) ; l.push_front(95); list <int>:: iterator it=l.begin(); while(it!=l.end()) { cout<<*it<<endl; it++; } }
20th Apr 2020, 5:59 PM
Amit singh
Amit singh - avatar
0
My code some basic type That'swhy i am looking for smart code!!! I want a code such that input loop stop as soon as user stop entering values
20th Apr 2020, 6:07 PM
Amit singh
Amit singh - avatar