I have written the program for readability to count the letters, words, and sentences and it does that. However, when printing the counted letters, words, sentences it does not just give me the total number of each but prints the whole sequence of the counting process. I know I am missing something simple. Please help!
include
include
include
include
include
int main(void) { //Takes input from users string s = get_string("Text: "); int letters = 0; int words = 1; int sentences = 0;
for (int i = 0; i < strlen(s); i++)
{
//Count letters
if (isalpha(s[i]))
{
letters++;
}
//Count words
else if (isblank(s[i]))
{
words++;
}
//Count sentences
else if (s[i] == '.' || s[i] == '?' || s[i] == '!')
{
sentences++;
}
//prints sum of counts
printf("%i Letters, %i Words, %i Sentences \n", letters, words, sentences);
} }