Hey all I have another riveting problem from my genius professor T_T. I have to make a program using functions, reference Parameters and full string words. Now if it were just a single letter at a time this would be easy. But it wants us to let the user enter in a whole word, and I have to have the program look at each letter and test it. It give me these operators to use string.str , string.length Kinda clueless on this sense she did her usual and didnt tell us how to do this stuff before hand. Here is my code:
#include <iostream>
#include <string>
using namespace std;
void countVowels(string str, int& aCt, int& eCt, int& iCt, int& oCt, int& uCt,int& nV);
int main()
{
string inputString;
cout << "Please enter a word and we will tell you how many vowels are in it!" << endl;
getline(cin,inputString);
countVowels(inputString);
}
void countVowels (string s, int& aCont, int& eCont; int& iCont; int& oCont; int& uCont int& nonVowl)
{
string.str(s)
while (string.str(s) <= s)
{
if (string.at(s) == 'a')
aCont++;
else
if (string.at(s) =='e')
eCont++;
else
if(string.at(s) == 'i')
iCont++;
else
if(string.at(s) == 'o')
oCont++;
else
if (string.at(s) == 'u')
else nonVowl++;
string.str(s)++;
}
}
Forgive me if its 100 percent off, but as ive said im quite clueless on what I have to do.