I am a newbie to C programming. I'm practicing to read the user input through an infinite while loop, and check if the input is a vowel or constant. I use a switch to check it, however when I execute my code, the default case is always executed, and I got stucked.
Would be appreciate if anyone can give me some advice, thanks!
#include <stdio.h>
void checkIfVowel(char *c);
int main()
{
char c;
while (1)
{
printf("Please enter a character: ");
scanf("%c", &c);
checkIfVowel(&c);
}
return 0;
}
void checkIfVowel(char *c)
{
switch (*c)
{
case 'A':
printf("%c is a vowel! \n", *c);
break;
case 'E':
printf("%c is a vowel! \n", *c);
break;
case 'I':
printf("%c is a vowel! \n", *c);
break;
case 'O':
printf("%c is a vowel! \n", *c);
break;
case 'U':
printf("%c is a vowel! \n", *c);
break;
case 'a':
printf("%c is a vowel! \n", *c);
break;
case 'e':
printf("%c is a vowel! \n", *c);
break;
case 'i':
printf("%c is a vowel! \n", *c);
break;
case 'o':
printf("%c is a vowel! \n", *c);
break;
case 'u':
printf("%c is a vowel! \n", *c);
break;
default:
printf("%c is a constant! \n", *c);
break;
}
}