Having trouble with a string function need help please
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?
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")
int main ()
cout << "Please type a word: ";
cin >> str;
cout << "There are " << count_vowels << "vowels";
Line 11 you made a mistake that can happen, you typed in the wrong member function, it should be.
string letter = str.substr(i,1);
Line 25 you do not need to create a variable count_vowels since your function can return this value. Also, that variable has the same name as your function, probably not a good idea because of confusion. So comment it out for now then make one more change.
Line 29 don't use that variable you were creating instead just invoke your vowel count function, like so.
cout << "There are " << count_vowels(str) << "vowels";
And one last note, the error you got was for trying to pass 2 variables to the str.length function. And you'll also get a warning for trying to use a variable without initializing it or setting it to a value, like Line 29 was doing.
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...
OK, so HostGator for some reason no longer allows gcc/g++ access unless you have a Designated Server account, which is a lot of money to spend just to compile my "Hello World" program. Thus I figured I'd compile at home, then upload. Program is your regular old bare-bones Hello World ...
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.