Simon Josefsson writes: > > Looking at the code, it seems it depends on whether feof() return true > immediately after fopen on a zero-size file. Does the standards says > anything about this?
Not explicitly, but there's nothing to suggest that fopen() can set the end-of-file indicator for the stream. The intent is certainly that only read operations set it. You could probably finesse the whole issue by reverting to the previous code and changing the while loop to a do-while loop instead. That would also have one additional benefit: Whenever I see "while (!feof(...))", it's a red flag that whoever wrote the code doesn't understand how EOF works in C and the code should not be trusted. Seeing "do {...} while (!feof(...));" doesn't raise the same flag. -Larry Jones See if we can sell Mom and Dad into slavery for a star cruiser. -- Calvin