Quote Originally Posted by ratneshp View Post
I think you should not call fgetc() in a for loop , it should be called in a while loop till EOF.
I'm not saying it's pretty, but how about:
for(i = 1; i < line && (c = fgetc(fp)) != EOF; i += (c == '\n')) ;
That would call fgetc() in a for loop, but also do the required checking foe EOF.