Posted by: comingsoon October 25, 2013
Login in to Rate this Post:
0
?
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;
}
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