#include?"stdlib.h"
int?main()
{
FILE?*fp=NULL;
int?count[26]={0},i;
char?fileName[40]={0};
char?ch;
printf("Please?input?file?name:");
gets(fileName);
if((fp=fopen(fileName,"r"))==NULL)
{
printf("File?read?failed!\n"); exit(0);}
while((ch=fgetc(fp))!=EOF)
{
if(ch>='A'&&ch<='Z')
count[ch-'A']++;if(ch>='a'?&&?ch<='z')
count[ch-'a']++;?}
fclose(fp);
if((fp=fopen("result.dat","w"))==NULL)
{
printf("File?read?failed!\n"); exit(0);}
fprintf(fp,"character?count\n");
for(i=0;i<26;i++)
fprintf(fp,"%c?%d\n",i+'a',count[i]);fclose(fp);
}