My program works.... but when I execute it, and input the sentence, I have to push enter twice in order for the rest of the program to execute. What do I need to change so that I only have to push enter once for the rest to follow through?
Code:#include <iostream> #include <string> #include <algorithm> using namespace std; int isVowel(string mystring); int main() { string vowelcheck; cout << "Enter a sentence: " << endl; getline(cin, vowelcheck, '\n'); cout << "There are " << isVowel(vowelcheck) << " vowels in this sentence." << endl; return 0; } int isVowel(string mystring) { int numvow = 0; transform (mystring.begin(), mystring.end(), mystring.begin(), tolower); string::iterator forward; for(forward = mystring.begin(); forward != mystring.end(); forward++) { if(*(forward) == 'a' || *(forward) == 'e' || *(forward) == 'i' || *(forward) == 'o' || *(forward) == 'u' ) { numvow++; } } return numvow; }



LinkBack URL
About LinkBacks


