-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile9.c
More file actions
29 lines (27 loc) · 717 Bytes
/
Copy pathfile9.c
File metadata and controls
29 lines (27 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <stdio.h>
int main()
{
char fileName[20] = {0}; //initialise
int currentChar;
int freequncy[26] = {0};
FILE *fp;
printf("Enter a filename you want to test:");
scanf("%s", fileName);
fp = fopen(fileName, "r");
if (fp!=NULL)
{
while (!feof(fp))
{
currentChar = fgetc(fp);
if (currentChar>= 'a' && currentChar <= 'z')
freequncy[currentChar - 'a']++;
}
}
printf("Total Appearances of Lowercase Letters in file '%s' : \n", fileName);
int i;
for (i = 0; i < 26; i++)
{
printf("Letter '%c' appears '%d' times\n",i + 'a', freequncy[i]);
}
return 0;
}