Vous êtes sur la page 1sur 1

#include<stdio.

h>
#include<stdlib.h>
int main()
{
char ch,c,ck,e,file1[100];
int count=0;
FILE *fp;
printf("Enter the file name\n");
scanf("%s",file1);
scanf("%c",&e);
fp=fopen(file1,"r");
printf("Enter the character to be counted\n");
scanf("%c",&c);
ck=c;
if(c>='A' && c<='Z')
c=c+32;
else if(c>='a' && c<='z')
c=c-32;
while((ch=fgetc(fp))!=EOF)
{
/* if(ch>='A' && ch<='Z')
ch=ch+32;
else if(ch>='a' && ch<='z')
ch=ch-32;*/
if(ch==c || ch==ck)
count++;

}
printf("File '%s' has %d instances of letter '%c'.",file1,count,ck);
fclose(fp);
return 0;

Vous aimerez peut-être aussi