I'm new to C, and I'm looking to write a program that takes a word, say "Aloha" as input, notes all the vowels and consonants in the word, and counts the number of characters in the word.
I've created the functions to determine if a single character is a vowel or consonant in the Hawaiian language, but I don't know how to make the program read more than one character as input. For example, in the code below
#include <stdio.h>
int is_vowel(char);
int is_consonant(char letter);
int main() {
char letter;
int vowel, consonant;
printf("Please input a Hawaiian word:");
scanf("%c", &letter);
vowel = is_vowel(letter);
consonant = is_consonant(letter);
if (vowel == 1) {
printf("%c is a vowel. \n", letter);
} else {
printf("%c is not a vowel. \n", letter);
}
if (consonant == 1) {
printf("%c is a consonant. \n", letter);
} else {
printf("%c is not a consonant. \n", letter);
}
}
when the user inputs "Aloha", the output is "A is a vowel. A is not a consonant", then it stops.
Instead of "A is vowel, A is not consonant. l is not a vowel, l is a consonant" etc etc.
How do I get C to read all the characters in the input one at a time, and get the function (not included in the sample code) to check each of them?
Thanks!