//File char count and line count
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
FILE *fp;
char ch;
int line=1,c=1;
clrscr();
fp=fopen("C:\\abc.txt","r");
if(fp==NULL)
{
puts("File not found");
exit(0);
}
while(1)
{
ch=fgetc(fp);
if(ch==EOF)
break;
c++;
if(ch=='\n')
line++;
}
fclose(fp);
printf("Total characters =%d\n",c);
printf("line count =%d",line);
getch();
}
Subscribe to:
Post Comments (Atom)
Related Post
Array:
String functions:
General (Loops-for/while)
No comments:
Post a Comment