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
What is static and volatile in c?
Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create.
Write a program to swap two numbers without using third variable in c?
What is the c language function prototype?
write a program to display all prime numbers
What is const keyword in c?
Why c is a procedural language?
What does %p mean?
Why main is used in c?
void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }
if the area was hit by a virus and so the decrease in the population because of death was x/3 and the migration from other places increased a population by 2x then annually it had so many ppl. find our the population in the starting.
What is void pointers in c?
what is the different bitween abap and abap-hr?
Function calling procedures? and their differences? Why should one go for Call by Reference?
What is bubble sort technique in c?