Answers for "how to remove blank spaces in a string"

C++
6

how to remove spaces from a string

#include <algorithm>

int main()
{
    std::string str = "H e l l o";
    str.erase(remove(str.begin(), str.end(), ' '), str.end());
    std::cout << str; // Output Hello
    
    return 0;
}
Posted by: Guest on November-10-2020

Code answers related to "how to remove blank spaces in a string"

Browse Popular Code Answers by Language