直接上代码
#include <algorithm>
#include <string>
int main()
{
std::string str = "Hello World";
str.erase(std::remove_if(str.begin(), str.end(), [](char c) {
return (c == ' ');
}), str.end());
std::cout << str;
return 1;
}