Hey guys just a quick question that has been bugging me with some of my code.
I've just been testing while loops with some of my code. The code that I'm writing now is pretty straight forward, it reads a line of data, stores in into c strings and does some stuff with the strings. But the while loop that I'm using seems to be going outside of the range of the array by 1 everytime.
If you know the number of students beforehand is 2, or know that your array can only hold 2 students, you can use while(i < 2). Otherwise, you can use vectors instead of arrays to store data.
You should also consider using getline() instead of get(), then you wouldn't need to worry about ignoring the delimiter. The getline() function extracts and discards that delimiter.
I would also recommend you use C++ strings instead of the C-strings, and vector instead of the array and use a structure to group the data instead of the discrete variables.