fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm> // remove_if
  4.  
  5. int main() {
  6. std::string string("S P A C E S");
  7. std::cout << string << std::endl;
  8.  
  9. string.erase(std::remove_if(string.begin(), string.end(), ::isspace),
  10. string.end());
  11.  
  12. std::cout << string << std::endl;
  13. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
S P A C E S
SPACES