Partial Arrays using negative and positive numbers

In a program with a partial array with max of 50 that contains negative and positive integers, how would you keep track of how many were filled? For example is code that works, but only for positive numbers:

cout << "Please enter up to " << MAX_ENTERIES
<< " integer numbers seperated by a space.\n"
<< "Hit enter to continue.\n";

int next, index = 0;

cin >> next;
while ((next >= 0 ) && (index < size))
{
num[index] = next;
index++;
cin >> next;
}

numberUsed = index;
It sounds like you should take a long hard look through that code, line by line. On each line, be sure that you understand everything that it does.

After that, you'll know the answer to your question and know a little more about C++.
Use a vector.
Topic archived. No new replies allowed.