Trying to build a vowel counting function for test practice but I am new to coding and can't figure out how to get the a char pointer to work correctly. What am I doing wrong?
int vowelCount(int index, char phrase[])
{
int count = 0;
if(phrase[index] == '\0')
{
return 0;
}
if(phrase[index] == 'a' || phrase[index] == 'e' || phrase[index] == 'i' || phrase[index] == 'o' || phrase[index] == 'u')
{
count = count + 1;
}
if(phrase[index] == 'A' || phrase[index] == 'E' || phrase[index] == 'I' || phrase[index] == 'O' || phrase[index] == 'U')
{
count = count + 1;
}
vowelCount(index + 1, phrase);
return count;
}
int main (void)
{
char array[1000];
int index = 0;
char inputPhrase;
printf("Please enter a phrase: ");
scanf("%c",&inputPhrase);
while(inputPhrase != '\n')
{
array[index] = inputPhrase;
index = index + 1;
scanf("%c",&inputPhrase);
}
array[index] = '\0';
index = 0;
while(array[index] != '\0')
{
printf("%c",array[index]);
index = index + 1;
}
index = 0;
int numberOFvowels = vowelCount(index,array);
printf("\n\nThere are %i vowels in the phrase.",numberOFvowels);
}