Sentence Analyzer In this problem you will design and implem
Solution
// C program textAnalyzer.c
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
#include <string.h>
int main(int argc, char const *argv[])
{
if(argc < 2)
{
printf(\"Input file missing\ \");
return 0;
}
FILE *inputFile;
int i;
char ch;
int characterCount[26] = {0};
// open file
inputFile = fopen(argv[1],\"r\");
while(!feof(inputFile))
{
ch = fgetc(inputFile);
ch = tolower(ch);
characterCount[ch - \'a\']++;
}
printf(\"Character frequency in infile.txt\ \");
printf(\"Character\\tCount\ \");
for(i = 0;i < 26;i++)
printf(\"%c\\t\\t%d\ \",97+i,characterCount[i]);
fclose(inputFile);
return 0;
}
/*
infile.txt
my name is ayush verma.
I am from bhopal madhya pradesh
I studied at IIT kharagpur.
pqrstwzyz
output:
Character frequency in infile.txt
Character Count
a 11
b 1
c 0
d 4
e 4
f 1
g 1
h 5
i 6
j 0
k 1
l 1
m 6
n 1
o 2
p 4
q 1
r 6
s 5
t 4
u 3
v 1
w 1
x 0
y 4
z 2
*/

