fork(1) download
  1. #include <iostream> // avoid old style MSVC++ header!
  2. #include <algorithm>
  3. #include <string>
  4.  
  5. static inline bool isvowel(char ch)
  6. {
  7. static const std::string vowels("aeiouEAIOU");
  8. return vowels.end() != std::find(vowels.begin(), vowels.end(), ch);
  9. }
  10.  
  11. int main()
  12. {
  13. std::cout << "Enter a name: ";
  14.  
  15. std::string name;
  16.  
  17. if (std::cin >> name) // handle errors
  18. {
  19. size_t vow_cnt = std::count_if(name.begin(), name.end(), isvowel);
  20. std::cout << "vow_cnt: " << vow_cnt << std::endl;
  21. }
  22.  
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 2728KB
stdin
Standard input is empty
stdout
Enter a name: