Event Controlled Looping in C++
Hi!
For an assignment I'm trying to read a set of integers from a file and store them in an array. Instead of reading ALL of them, we are suppose the loop is suppose to stop when we reach a -1. I'm attemping to do it with this:
(ps sin is the name of my file variable)
while (1)
{
sin >> x[a];
if (x[a] = -1)
break;
a++;
}
With no luck.
Is there a better way I can create an event controlled loop where my function will stop reading from the file when it reads a -1 as the integer?
Thanks!
|