for (int i = 0; i < 4000; i++ )
mmm... , this is a bad method, your loop will read past the end of the file, you should use a while loop instead, this way, the loop automatically stop whenever it encounters the end of file,
~~~~~~~~~~~
Basically what I need is a loop setup that will get the first values put them in array a, then skip spaces put next set of values into array b, then skip spaces and put final values into array c. |
you can do something like :
1 2 3 4 5 6 7 8 9 10 11 12
|
int num[ 100 ];
int bla[ 100 ];
char some_name[ 100 ];
int index = 0;
while( in >> num[ index ] )
{
in >> bla[ index ];
in >> some_name[ index ];
++index;
}
|
as simple as that, since after cin >> encounters spaces, newlines etc.. it "skips" to the next available character to read ( which of course is not a space, newline tab... )
~~~~~~~~~~~
and store the spaces into a separate temporary array |
Nahh, spaces aren't read by >> operator, it skips it ( and also newlines, tabs, etc... )
~~~~~~~~~~~
Then (since there is an endline) start first array with the new line |
as i said, newlines is skipped with >> operator