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.
Alan,
Are you opening the file in text mode? If you are, try opening it in
binary mode.
Re: K&R 1.5.1 exercise ... Your while loop will eventually cause integer overflow, ... > It would have been even better if you used a loop, with getchar!= EOF... > getchar() call will return the code of the first character you have typed ... (comp.lang.c)
Re: to get more knowledge in c ... That will be a value from 0 to UCHAR_MAX if successful, and a negative value called EOF if unsuccessful. ... Each time through the loop, there is a complex expression that is evaluated. ... You can test whether you have read a space, a newline character, or some other type like this: ... There is a tricky part though, as you will be reading the space characters before the newline comes in. ... (comp.lang.c)
Re: Buffered socket I/O with sysread-style blocking? ... because using select you know not to call until at least one character... >> blocking or select loop stuff. ... (or eof condition) ... socket has nothing to do with buffering or how you read it. ... (comp.lang.perl.misc)
Re: K&R 1.5.1 exercise ... It would have been even better if you used a loop, with getchar()!= EOF... getcharcall will return the code of the first character you have typed ... (comp.lang.c)