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
Can 'this' pointer by used in the constructor?
How do you determine a file’s attributes?
Create a simple code fragment that will swap the values of two variables num1 and num2.
Write the program with at least two functions to solve the following problem. The members of the board of a small university are considering voting for a pay increase for their 10 faculty members. They are considering a pay increase of 8%. Write a program that will prompt for and accept the current salary for each of the faculty members, then calculate and display their individual pay increases. At the end of the program, print the total faculty payroll before and after the pay increase, and the total pay increase involved.
What type is sizeof?
What are file streams?
What do header files do?
Is there any demerits of using pointer?
How do you convert strings to numbers in C?
Design a program which assigns values to the array temperature. The program should then display the array with appropriate column and row headings.
What does *p++ do? What does it point to?
How to throw some light on the b tree?
Differentiate between new and malloc(), delete and free() ?
What is the purpose of scanf() and printf() functions?
Why enum is used in c?