Learn C, C++ Concepts
// Author-- Ashutosh Tripathi// www.facebook.com/omi.pro#include #includevoid main(){ FILE *fp; int c, ct_lines; ct_lines = 0; fp = fopen("foo.txt", "rb"); do { c = fgetc(fp); if (c == '\n') ct_lines++; } while (c != EOF); fclose(fp);printf("Number of lines are: %d"ct_lines);getch();}
Hi Ashutosh,That too will work.I have presented a generic example which will take the input from us.Thanks,Saurabh Guptasaurabh.gupta@ccplusplus.com
// Author-- Ashutosh Tripathi
ReplyDelete// www.facebook.com/omi.pro
#include
#include
void main()
{
FILE *fp; int c, ct_lines;
ct_lines = 0;
fp = fopen("foo.txt", "rb");
do {
c = fgetc(fp);
if (c == '\n')
ct_lines++;
} while (c != EOF);
fclose(fp);
printf("Number of lines are: %d"ct_lines);
getch();
}
Hi Ashutosh,
DeleteThat too will work.
I have presented a generic example which will take the input from us.
Thanks,
Saurabh Gupta
saurabh.gupta@ccplusplus.com