fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4. #include <cctype>
  5. using namespace std;
  6.  
  7. int main() {
  8.  
  9. std::string str = "This is test of vowel aeiou to be removed. Also the upper case AEIOU.";
  10. std::cout << "Original String: " << str << std::endl;
  11.  
  12. str.erase(std::remove_if(str.begin(), str.end(), [](char x) {
  13. if (x == 'a'|| x == 'e' || x == 'i' || x == 'o' || x == 'u' || x == 'y'
  14. || x == 'A'|| x == 'E' || x == 'I' || x == 'O' || x == 'U' || x == 'Y')
  15. {
  16. //std::cout << "True: " << x << std::endl;
  17. return true;
  18. }
  19. else
  20. {
  21. //std::cout << "False: " << x << std::endl;
  22. return false;
  23. }
  24. }),
  25. str.end());
  26.  
  27. std::cout << "String with vowels removed: " << str << std::endl;
  28. return 0;
  29. }
Success #stdin #stdout 0s 3276KB
stdin
Standard input is empty
stdout
Original String: This is test of vowel aeiou to be removed. Also the upper case AEIOU.
String with vowels removed: Ths s tst f vwl  t b rmvd. ls th ppr cs .