c++ remove whitespace from string
#include <iostream>
#include <string>
#include <algorithm>
int main() {
std::string str = " Hello, this is a sample string ";
str.erase(std::remove_if(str.begin(), str.end(), ::isspace), str.end());
std::cout << str;
return 0;
}