I was given an assignment by my professor to type a program that will count the
ID: 665657 • Letter: I
Question
I was given an assignment by my professor to type a program that will count the occurance of the letters in a given phrase. For example -
Input: "The Fox Jumps up on the log"
Output:
t - 2, h - 2, e - 2, f - 1, o - 3, x - 1, j - 1, u - 1, m - 1, p - 2, s - 1, n - 1, l - 1, g -1.
In this case, we are given the text file containing "xyxabcabcdabcdefa" and so the output should be:
x - 2, y - 1, a - 4, b - 3, c - 3, d - 2, e - 1, f - 1
However, I have a problem. We are completing the task using the structure:
In the main, we have to input the text file INTO the structure. The professor has given us a main with a piece missing that we need to fill out in order to complete this task. I have the rest of my code completed but I can't test it unless I complete the missing section in the main. It's probably the most simple thing but I'm somehow stumped. Our main is given as:
I'd appreciate the help!
Explanation / Answer
This is how main () should be
FILE *fptr;
char filename[15];
char ch;
And to count the number of characters it should be like this
i = 0;
while (ch[i] != '') {
if (ch[i] >= 'a' && ch[i] <= 'z')
i++
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.