I'm really starting to get the hang of this I think. This is now what I have and the only compiling problem I'm having is coming up with 2 errors when I build, but I have no idea what they mean. How's everything looking?
Code:
#include <iostream>
#include <string>
using namespace std;
bool isVowel(string);
int countVowels(char);
int sum;
char vowel;
int index;
string myString;
int main()
{
cout << "Enter a sentence" << endl;
getline(cin, myString);
cout << "There are " << countVowels(index) << " vowels in this sentence." << endl;
return 0;
}
bool isVowel(char vowel)
{
if (vowel =='A' || vowel =='a' || vowel =='E' ||
vowel =='e' || vowel =='I' || vowel =='i' ||
vowel =='O' || vowel =='o' || vowel =='U' || vowel =='u')
return true;
else
return false;
}
int countVowels(string)
{
for (index = 0; index < myString.length(); index++)
{
if (isVowel(vowel) == true)
sum = sum + 1;
else sum = sum;
}
return sum;
}