I\'m having a hard time with a do-while loop, that is supposed to stop when we reach the end of the file. Here\'s the loop code:
do {
if (pcompanyRow[0]
I suggest use both fgets() and feof(). Last string in file might have \n or might not. If you use only feof(), you can skip (lost) last line.
for(;;)
{char *pc;
pc=fgets(buf,sizeof(buf),fd);
if(!pc)
{//it may be read error or end of file
if(feof(fd))
{//it is end of file, normal exit from for
break;
}
else
{//it is i/o error
fclose(fd);
return 2;
}
}
}//for