Counting parts in a string?

I've got to do a program that counts vowels, the user gives their input and the program outputs the number vowels the input has, it assignment says it HAS to use recursion so I can't find a way not to use it.

There's no errors in the system but it doesn't do what I want it to.

Here's what I got so far, I ended up making the strings into chars, because the switch didn't work

Basically I keep getting 0 as the output, I know counter is set to 0, but once it hits a vowel it should add counter++? That's what I want it to do. But I'm having a hard time getting anything but 0.

Here's my code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 void vowelCounter(char sentence, int counter)
{ 

	switch (sentence)
	case 'a':
	case 'A':
	case 'e':
	case 'E':
	case 'i':
	case 'I':
	case 'o':
	case 'O':
		counter++;

		if (counter = 0)
		{
			vowelCounter;
		}

		else
		{
			vowelCounter;
			cout << "The number of vowels is: " << counter << endl; 
		}

}

int main()
{
	char input;
	int c = 0;

	cout << "This program counts all the vowels in a sentence." << endl;
	cout << "Enter a sentence!" << endl;
	cin >> input; //get data from user

	vowelCounter(input, c); //Call function vowelCounter
	cout << endl;


	system("pause");
	return 0;
}
Topic archived. No new replies allowed.