Printable View
Quote: Originally Posted by ratneshp 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: Code: 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. -- Mats
for(i = 1; i < line && (c = fgetc(fp)) != EOF; i += (c == '\n')) ;