I am suppose to count the number of vowels in a user inputed string.
I dont know what i am doing wrong it gives me one error?
#include <iostream>
#include <string>
using namespace std;
int count_vowels(string str)
{
int count = 0;
for (int i = 0; i < str.length(); i++)
{
string letter= str.length(i, 1);
if ( letter == "a" || letter=="A" || letter == "e" || letter == "E" || letter == "i" ||
letter == "I" || letter == "o" || letter == "O" || letter == "u" || letter == "U")
{
count++;
}
}
return count;
}
int main ()
{
int count_vowels;
string str;
cout << "Please type a word: ";
cin >> str;
cout << "There are " << count_vowels << "vowels";
return 0;
}