fork download
  1. #include <string>
  2. #include <cstdarg>
  3. #include <iostream>
  4.  
  5. std::string string_replace(std::string s, char r, int countc, ...)
  6. {
  7. char p;
  8. va_list ap;
  9. va_start(ap, countc);
  10. for(int j = 0; j < countc; ++j)
  11. {
  12. p = va_arg(ap, char);
  13. for(char &c : s)
  14. {
  15. if(c == p)
  16. {
  17. c = r;
  18. }
  19. }
  20. }
  21. va_end(ap);
  22. return s;
  23. }
  24.  
  25. int main()
  26. {
  27. std::cout << string_replace("aeiou and sometimes y", 'z', 5, 'a', 'e', 'i', 'o', 'u') << std::endl;
  28. }
  29.  
Runtime error #stdin #stdout 0s 3424KB
stdin
Standard input is empty
stdout
Standard output is empty