This question is more philosophical than technical, but I'd be interested in hearing people's opinions.
I have a program that generates a file of hex numbers, in ASCII representation, one number per line. They're separated by the endl character. The file looks like:
long inI, inQ;
while (fileIn.good())
{
fileIn >> hex >> inI;
fileIn >> hex >> inQ;
...
What I believe is happening, is the final endl is getting picked up and causing the loop to go through an extra iteration. (I get 0 as input to inI and inQ.)
So, the question is: who's "fault" is this? Should the program generating the file strip off the final endl, or should the program reading it be smart enough to know that the final read is non-numeric? If there's any kind of industry convention for this, I'd like to follow it.