Given these requirements for a console application:
Enter a series of integers seperated by whitespace. The first integer represents the quantity of integers to follow.
Ex. 3 5 18 21
or. 5 17 -46 3 198 2

I have been attempting the following to read the integers and store them in a vector:
scanf("%d", &cnt);
for(int i = 1; i <= cnt + 1; i++)
{
scanf("%d", &n);
aInts.push_back(n);
}

This works fine, unless someone enters fewer integers than the initial integer indicates. (ex. 3 19 5)
How can I test to see if the end of the input stream has been reached?

I have attempted the same type of logic using cin, to no avail.

Thank you in advance for your help.