
While Loop Reading From File Ignores Last line if it contains data
Quote:
> I am having some trouble with the following while loop.
> <CODE>
> while(fgets(buffr, (buffrsize * AVG_LINE_SIZE) - 1, infile) != NULL &&
> !feof(infile)) {
> ..........do stuff to buffr
> }
> </CODE>
I'm not surprised. Remove the !feof() condition. And the second
argument to fgets() looks suspicious, too: is buffr declared as
char buffr[(buffrsize * AVG_LINE_SIZE) - 1];
or is there something funny going on?
--
"The way I see it, an intelligent person who disagrees with me is
probably the most important person I'll interact with on any given
day."
--Billy Chambless