How to enter more than one number in cin

closed account (ENh0ko23)
Say i Debug my code and it asks me to enter numbers. IF i want to enter more than one number in the cin part, what code would i use?
like i know it would probably be something like

1
2
3
4
int nums;
cout <<" Enter your numbers." <<endl;
cin >> nums


but my question is how do i enter more than one number in the cin without having to put num1, num2, num3 and so on
What's wrong with using "num1, num2, num3"? if you know your inputting 3 numbers that works well. If you don't know how many you'll be entering you can use a loop and something like a vector to store inputs.
closed account (ENh0ko23)
Oh ok my situation is the 2nd option you mentioned. I am not sure how many numbers i will be using.
Ok I would suggest checking out: http://www.cplusplus.com/doc/tutorial/control/
Scroll down to the loops(while loops, do while, and for loop)
1
2
3
4
5
6
7
8
9
10
11
12
13
//best way
int num1,num2,num3;

cin >> num1 >> num2 >> num3;

//your code
cin >> nums;

//my input
//12457814564819849

//go use my input and compute


enter your numbers for what?

Last edited on
Topic archived. No new replies allowed.