Hi there, iv recently got this question:
Write a fully modular C program that reads in a string of a defined size from the keyboard and reports how many times each letter of the alphabet occurs within that string (ignoring case). It should also report how many non-letters are included in the string.
I understand what it's asking me to do, i just can't get my head around a function that reports how many times each letter of the alphabet occurs/how many non letters occur within the string without using a giant switch-case statement.
Any help with regards to how i could report how many times each letter of the alphabet/ how many non letters occur within the entered string would be greatly appreciated. I'm not asking someone to do it all for me, just point me in the right direction .
Here's my code so far that reads in a string and converts it to lower case. I know it's not much.. but it's a start.
Code:
#include <stdio.h>
#include <string.h>
void readin(char line[])
{
printf("Enter string: ");
scanf("%s", line);
strlwr(line);
return;
}
{
const int MAXSIZE = 100;
char line[MAXSIZE] = {'\0'};
readin(line);
return(0);
}