For some reason I am having some trouble reading a list of numbers using cin into an array, using -1 to indicate I am done.
For example, the program will prompt for numbers and I will enter: 1 2 3 4 5 -1 and I would want those 5 numbers (1 2 3 4 5) to be stored into an array. I am having trouble doing that!
I was able to get it done using an input stream, but I can't get it right with cin. Here is my input stream code:
1 2 3 4 5 6 7 8 9 10 11
nums[50];
ifstream input;
int count = -1;
input.open("nums.txt");
do
{
count++;
input >> nums[count];
}while(nums[count] != -1);
This stores it perfectly fine using an input stream, how would I use in cin instead? Any help would be greatly appreciated!!!