Hello,
I am writing a program using getchar() that reads characters from the keyboard until the # sentinnel character in encountered. The program should count the number of occurrences of the letters a, b, and c.
I am goig pretty good here but ran smack into the damn wall with the last sentence. where can i get help from here. How do i get it to count the number of letters a,b, and c?
TOTALLY BODACIOUS!
#include<stdio.h>
#include<ctype.h>
int found_next_word(void);
int main(void)
{
int word_count=0;
while (found_next_word() == 1)
++word_count;
printf("Number of words = %d\n\n", word_count);
int found_next_word();
return 0;
}
int found_next_word(void)
{
int c;
while (isspace(c = getchar()))
;
if (c == '#')
printf("You can not use this # symbol. Please try again.\n");
while (c == '#')
return 0;
if (c != EOF) {
while ((c = getchar()) != EOF && !isspace(c))
;
return 1;
}
return 0;
}