0
How to enter/insert value into object of list class(STL) from user in c++
I have learn the basic of c++
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
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++;
}
}
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