Ass 6 A 1
Ass 6 A 1
h>
#include<stdlib.h>
void main()
{
FILE *fp;
char ch,c,fname[20];
int count=0;
printf("Enter the filename:");
scanf("%s",fname);
fp=fopen(fname,"r");
printf("Enter the character");
scanf(" %c",&c);
if(fp==NULL)
{
printf("File opening error");
exit(0);
}
while (!feof(fp))
{
ch=fgetc(fp);
printf("%c",ch);
if(ch==c)
count++;
}
printf("Total count for character %c =%d",c,count);
fclose(fp);
}