tag:blogger.com,1999:blog-8525919027680721883.post6941604026848240203..comments2024-03-29T09:37:16.378+05:30Comments on ccplusplus.com: c program to count number of lines in a fileSaurabh Guptahttp://www.blogger.com/profile/00311810578585599874noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-8525919027680721883.post-33951414484275874512012-01-30T09:19:09.837+05:302012-01-30T09:19:09.837+05:30Hi Ashutosh,
That too will work.
I have presented...Hi Ashutosh,<br /><br />That too will work.<br />I have presented a generic example which will take the input from us.<br /><br />Thanks,<br />Saurabh Gupta<br />saurabh.gupta@ccplusplus.comSaurabh Guptahttps://www.blogger.com/profile/00311810578585599874noreply@blogger.comtag:blogger.com,1999:blog-8525919027680721883.post-90577424873230471272012-01-30T00:37:57.629+05:302012-01-30T00:37:57.629+05:30// Author-- Ashutosh Tripathi
// www.facebook.com/...// Author-- Ashutosh Tripathi<br />// www.facebook.com/omi.pro<br /><br />#include <br />#include<br />void main()<br />{<br /> FILE *fp; int c, ct_lines;<br /> ct_lines = 0;<br /> fp = fopen("foo.txt", "rb");<br /> do {<br /> c = fgetc(fp);<br /> if (c == '\n')<br /> ct_lines++;<br /> } while (c != EOF);<br /> fclose(fp);<br />printf("Number of lines are: %d"ct_lines);<br />getch();<br />}Ashutosh Tripathihttp://www.facebook.com/omi.pronoreply@blogger.com