How to count line in c?

Archived from the original Sajha.com — preserved as posted, replies can no longer be added here.
Start a New Discussion
Archived Post

I try this way and good fail many time. Any help, will be celebrate with grate appreciation. Thanks. I also try fgets() same way but didn't work as well. int line_count () {     FILE * fp;         // file open from here.     int i=0;     int c;     if ((fp = fopen ("file.txt", "a")) != NULL){         while ((c=fgetc(fp))!=EOF)         {             if (c=='\n') {                 i++;             }                     }         fclose(fp);     }     else printf(" Error.\n");     return i; } Last edited: 25-Oct-13 04:52 PM Last edited: 25-Oct-13 04:54 PM

comingsoon · Oct 25, 2013 4:48 PM · 9,994 views

Replies
No replies yet.

This conversation is preserved exactly as it was on the original Sajha.com and can't accept new replies.

Start a New Discussion