H
H.
I'm writing a driver for something I wrote, and can't remember how to
do this very simple thing. The code I have at this point in time:
int myArr[100];
int temp;
int ind = 0;
cout << "enter some integers: ";
while (cin >> temp)
{
myArr[ind++] = temp;
}
The problem is that it doesn't exit until the user enters a non-number.
It won't exit if the user simply hits enter.
What I'm trying to create is something that allows the user to separate
values by spaces, and press the Enter key when done entering them. A
variable number of items will be separated by spaces, e.g.:
"Enter the integers to be sorted with spaces between them and Enter to
finish"
do this very simple thing. The code I have at this point in time:
int myArr[100];
int temp;
int ind = 0;
cout << "enter some integers: ";
while (cin >> temp)
{
myArr[ind++] = temp;
}
The problem is that it doesn't exit until the user enters a non-number.
It won't exit if the user simply hits enter.
What I'm trying to create is something that allows the user to separate
values by spaces, and press the Enter key when done entering them. A
variable number of items will be separated by spaces, e.g.:
"Enter the integers to be sorted with spaces between them and Enter to
finish"