0% found this document useful (0 votes)
46 views1 page

Ass 6 A 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views1 page

Ass 6 A 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

#include<stdio.

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);
}

You might also like