Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// http://www.cplusplus.com/forum/beginner/75558/
- #include <iostream>
- #include <string.h>
- #include <cstdlib>
- #include <algorithm>
- bool vowel(std::string str);
- void remove(std::string & str);
- int main()
- {
- std::string word;
- std::cout << "Welcome to the vowel remover! enter any word: ";
- std::cin >> word;
- if(!vowel(word))
- std::cout << "No vowels detected in: " << word << ".\n";
- else
- remove(word);
- }
- bool vowel(std::string str)
- {
- std::transform(str.begin(), str.end(), str.begin(), ::tolower);
- for(int i = 0;i<str.length();i++)
- {
- if(str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u')
- return true;
- }
- return false;
- }
- void remove(std::string & str)
- {
- std::string vowellesswrd;
- for(int i = 0; i < str.length(); i++)
- {
- std::string temp;
- temp = str[i];
- if(!vowel(temp))
- vowellesswrd += str.substr(i,1);
- }
- std::cout << str << " with no vowels becomes: " << vowellesswrd << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement