← Back to Kurakani

How to count line in c?

Original 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.
Login to join the conversation.

You might be interested in...

Recent Classifieds View all
Upcoming Events View all
Service Providers View all
Ask Sajha AI Assistant