how can I stop adding values

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include<iostream>
#include<list>

using namespace std;

int main()
{
    list<int> L;

    int num;
    for(int i = 0 ; i < 10 ; i++)
    {
        cin >> num;
        L.push_back(num);
    }
}


in this case I gust can only add 10 values



How can i make my program receives values from the user and stops only when the user pressure of any button other than numbers?

sorry for my bad english
while( cin>>num )
Don't send garbage, indicate the end instead.
OK,

thank u so much bro.
Topic archived. No new replies allowed.