C program to find frequency of each character in a text
file?
Answer Posted / vadivel
#include <stdio.h>
int count[26];
int main()
{
FILE *f;
int i;
char ch;
f = fopen("capti.c","r");
while(!feof(f))
{
ch = fgetc(f);
count[ch - 'a']++;
}
for(i = 0;i < 26;i++)
printf("count[%c] = %d\n",65+i,count[i]);
fclose(f);
return 0;
}
//asuming only lower characters are required
| Is This Answer Correct ? | 38 Yes | 23 No |
Post New Answer View All Answers
Why doesnt long int work?
How will you print TATA alone from TATA POWER using string copy and concate commands in C?
What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?
what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?
Do you know what are the properties of union in c?
What are the differences between Structures and Arrays?
Is python a c language?
What is c variable?
When should the volatile modifier be used?
Can a function argument have default value?
Write a program to reverse a linked list in c.
What is the difference between typedef struct and struct?
When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?
What is #define in c?
What is double pointer?