Trouble at EOF

Ed Nilges EGNILGES at pucc.Princeton.EDU
Mon Jun 17 03:04:35 AEST 1991


According to the description of the standard fgets library function
(reference 1), you are not guaranteed newline at the end of every
line...that is, you'll get one at the end of the LAST line (or is
it the last-1th line, such that the last line is zero length?
enquiring minds want to know) only if it's there in the file.
I guess it's the old IBMer in me, who wants the end of a line to
be the Edge of the World, but this seems a tad bogus, especially
if one is writing a lexical analyser where such issues are
important.  Is there a true line reader in C? One that would
slap on an end of line at the end of the last line if it needed
it?



More information about the Comp.lang.c mailing list