Quote:Original post by kingpinzs
*** Source Snippet Removed ***
This is how it is easyer to use
It's just as easy with std::string:
char menu();int vowel_counter(const std::string&);int consonants_counter(const std::string&); void cls( HANDLE );int main(){ std::string input; cout<<"Enter a string "; std::getline(std::cin, input); char menu_input = menu(); while(toupper(menu_input) != 'E') { if(toupper(menu_input) == 'A') { cout<<"The number of vowels in your string is "<<vowel_counter(input)<<endl; cout<<"Press a key to continue"<<endl; cin.ignore(); cin.get(); } else if(toupper(menu_input) == 'B') { cout<<"the number of consonants in your string is "<<consonants_counter(input)<<endl; cout<<"Press a key to continue"<<endl; cin.ignore(); cin.get(); } else if(toupper(menu_input) == 'C') { cout<<"The count of both consonants and vowels is "<<vowel_counter(input) + consonants_counter(input)<<endl; cout<<"Press a key to continue"<<endl; cin.ignore(); cin.get(); } else if(toupper(menu_input) == 'D') { cout<<"Enter a string "; cin.ignore(); cin.getline(input, SIZE); } menu_input = menu(); }cout<<"Exiting the program "<<endl;system("PAUSE");return 1;}char menu(){ HANDLE hConsole; hConsole = GetStdHandle(STD_OUTPUT_HANDLE);cls(hConsole);char input; cout<<"\t\tCount Vowels, Consonants or Both."<<endl<<endl; cout<<"\t A) Count the number of vowels in the string"<<endl <<"\t B) Count the number of consonants in the string"<<endl <<"\t C) Count both the vowels and consonants int the string"<<endl <<"\t D) Enter another string"<<endl <<"\t E) Exit the program"<<endl<<endl <<"\t Enter a letter "; cin>>input;return input;}int vowel_counter(const std::string& str){ char vowles[5]={'A', 'E','I', 'O', 'U'}; int counter = 0; for(size_t i=0; i<str.length() ++i) { for(int j=0; j<5; ++j) { if(toupper(str) == vowles[j]) { counter++; } } }return counter;}int consonants_counter(const std::string& str){char consonants[21]={'B', 'C','D', 'F', 'G', 'H' ,'J','K','L','M','N','P','Q','R','S','T','V','W','X','Y','Z'}; int counter = 0; for(size_t i=0; i<str.length() ++i) { for(int j=0; j<5; ++j) { if(toupper(str) == consonants[j]) { counter++; } } }return counter;}