fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <set>
  4. #include <algorithm>
  5. #include <cctype>
  6.  
  7. const std::set<char> vowels = {'a', 'e', 'i', 'o', 'u'};
  8.  
  9. bool isvowel(char c)
  10. {
  11. return vowels.count(std::tolower(c));
  12. }
  13.  
  14. int main()
  15. {
  16. std::cout << "Enter a string: ";
  17. std::string s1;
  18. getline(std::cin, s1);
  19. s1.erase(remove_if(s1.begin(), s1.end(), isvowel), s1.end());
  20. std::cout << '\n' << s1 << '\n';
  21. }
Success #stdin #stdout 0s 2992KB
stdin
Hello, World!
stdout
Enter a string: 
Hll, Wrld!