Write a C program to count the number of characters in a given file.

 

#include<stdio.h>
main()
{
FILE *fp;
int count=0;
clrscr ();
fp=fopen("vpt.txt","r");
while( getc(fp) != EOF)
{
count++;
}
printf("count=%d",count);
fclose(fp);
getch();
}

 

 

Output:
count=16
Txt File

 

 

Txt File

Download ProgramĀ