fork(2) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void change(string &str);
  6.  
  7. int main()
  8. {
  9. //setlocale(LC_ALL, "RUSSIAN");
  10.  
  11. string str = "The sun is hot.";
  12.  
  13. cout << str << endl;
  14. change(str);
  15. cout << str << endl;
  16.  
  17.  
  18. return 0;
  19. }
  20.  
  21. void change(string &str)
  22. {
  23. for (string::size_type i = 0; i < str.size(); ++i) {
  24. if (str[i] == ' ') {
  25. str.insert(i, ",");
  26. i++;
  27. }
  28. }
  29. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
The sun is hot.
The, sun, is, hot.