This code now works for single words. I just need it to work for a sentence now. I do have the appropriate header files it just doesn't let me include them for some reason. I have to use scanf_s. I have already tried scanf_s( "%s", word, 100)
, and it didn't work. Thanks for all the help so far.
void printIsVowel() {
int isVowel = 0;
int i;
char word[40] = "";
printf("Enter a Statement");
scanf_s("%s", word, 40);
for (i = 0; i < strlen(word); i++) {
if (tolower(word[i]) == 'a' || tolower(word[i]) == 'e' || tolower(word[i]) == 'i') {
isVowel++;
} else if (tolower(word[i]) == 'o' || tolower(word[i]) == 'u') {
isVowel++;
}
}
printf("The previous statement has %d vowels.\n", isVowel);
}
int main() {
printIsVowel();
system("pause");
return 0;
}