fork 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, str2;
  9.  
  10. cout << "Enter string: ";
  11. getline(cin, str);
  12.  
  13. len = str.length();
  14. str2.reserve(len);
  15.  
  16. for(i = 0; i < len; ++i)
  17. {
  18. char ch = str[i];
  19. if (ch != ' ')
  20. str2 += ch;
  21. }
  22.  
  23. cout << str2 << endl;
  24.  
  25. //system("pause");
  26. return 0;
  27. }
Success #stdin #stdout 0s 4540KB
stdin
Hello World    is this working?
stdout
Enter string: HelloWorldisthisworking?