file read picking up linefeed as numeric value

Hi -

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:

0000024e
0000024e
fffffdb2
fffffdb2
0000024e
0000024e
fffffdb2
fffffdb2
fffffdb2
0000024e
...


Another program reads this file with this code:

1
2
3
4
5
6
7
	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.

Thanks...
Topic archived. No new replies allowed.