fork(2) download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. size_t i, j, len;
  8. string str;
  9.  
  10. cout << "Enter string: ";
  11. getline(cin, str);
  12.  
  13. len = str.length();
  14.  
  15. i = 0;
  16. while (i < len)
  17. {
  18. if (str[i] == ' ')
  19. {
  20. for (j = i + 1; j < len; ++j)
  21. {
  22. str[j - 1] = str[j];
  23. }
  24. --len;
  25. }
  26. else
  27. ++i;
  28. }
  29.  
  30. str.resize(len);
  31.  
  32. cout << str << endl;
  33.  
  34. //system("pause");
  35. return 0;
  36. }
Success #stdin #stdout 0s 4280KB
stdin
Hello World    is this working?
stdout
Enter string: HelloWorldisthisworking?