Answers for "c++ remove whitespace and newlines from end of string"

C++
6

c++ remove whitespace from 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 "c++ remove whitespace and newlines from end of string"

Browse Popular Code Answers by Language