unexpected eof



Dear All,

I'm trying to write a C++ that reads in hexadecimal characters from a
text file. For this I use the >> to read in a character at a time
inside a while loop that waits for eof to be reached. I'm able to read
in correctly about half my text file, then the program breaks out of
the while loop.

I presume this is due to the fact that one of the hex characters that
I'm trying to read in, is equals to eof. I've tried to get around this
problem, by using file pointers to determine the size of the file and
then use a for loop to read in the corresponding amount of characters.
This doing, I can copy half the initial text file into another file,
with the rest being filled with rubbish.

Does anyone have any ideas how I could get around this problem?

Thanks in advance for your help,

Regards,

Alan

.



Relevant Pages

  • Re: malloc + 4??
    ... >the screen or to a file, there aren addition 4 characters. ... This loop tries to count the size of the file by calling getc ... until getcreturns EOF. ... yet also return the special marker value EOF. ...
    (comp.lang.c)
  • [SUMMARY] Word Loop (#149)
    ... cheater is a wonderful label for a programmer to have. ... the first priority is to find a possible loop. ... puts before+letter+looplets.shift ...
    (comp.lang.ruby)
  • Re: StrReverse() function - infinite loop
    ... also be a sequence of space characters at the beginning of a document, ... right-click aWord and choose Add to Watch. ... 'reverses' that space again and again in an infinite loop. ... Dim myRange As Range ...
    (microsoft.public.word.vba.beginners)
  • Re: count occurences of font color
    ... Dim num As Long, res As Long ... Debug.Print Timer - s ... ' using isnull and not using characters ... as the loop will exit on the first character. ...
    (microsoft.public.excel.programming)
  • Re: count occurences of font color
    ... Dim num As Long, res As Long ... Debug.Print Timer - s ... ' using isnull and not using characters ... as the loop will exit on the first character. ...
    (microsoft.public.excel.programming)