A minor point, you test this
1 2 3 4
|
if (first_iteration == false) {
}
else if (first_iteration == true) {
}
|
The second "if" is redundant.
1 2 3 4
|
if (first_iteration == false) {
}
else {
}
|
But onto the other points. Lines 72 to 76
1 2 3 4 5
|
else if (first_iteration == true) {
getline(inFile, strTmp); // chomp first line
first_iteration = false;
}
inFile.get(chTmp);
|
Two problems here. One, the getline will consume the 'newline' character, so the get() which follows takes the first character of the data, which mis-alighns all of the following reads.
Secondly, the getline() discards the first line of the file. While it does that, the loop counter i on line 57 is incremented by 1. That results in the first row of the data array being left empty, and the last data row is never read from the file.
Other points. stdtID[] is allocated with a length equal to the number of data rows in the file. Luckily in this case that is enough space to hold the 8-character id of a single student at a time. But it gets overwritten each time with the ID of the next student.
Suggestions. Move the code to discard the first line outside the loop.
Allocate space to store all the student IDs. I'd recommend allowing space for a null terminator, so that the ID can be printed an handled as a normal C-string. You may want to similarly make the storage for each stdtAN 21 chars long, to allow for a null terminator.
One more suggestion. Run your code with a debugger to trace the data values as the program executes.