You need to use getline() so you can save the data in strings. You can then convert the strings to integers. There's no way to directly read the data as integers.
#include <iostream>
usingnamespace std;
int main()
{
int a[10], i;
/* a for loop is just like a while loop, it just uses 'i' to
control how many times it should go through the loop */
for(i = 0; i < 10; ++i)
{
cin >> a[i]; //read an integer from the keyboard
if(a[i] == 0) break; //if a[i] is 0, break out from the loop
}
//output the content of "a"
for(int x=0; x <= i; ++x)
cout << a[x] << endl;
return 0;
}
As you may see though, there's a limit on how many integers you can enter (10, the maximum size of "a"). If you want to enter an "infinite" amount of numbers without setting a's capacity sky high, you need to use dynamic arrays. I think that may be a little too complicated for you right now though. If there's anything in this code you don't understand, don't hesitate to ask!