Horje
remove space in string c++ Code Example
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;
}
c++ remove space from string
static std::string removeSpaces(std::string str)
{
	str.erase(remove(str.begin(), str.end(), ' '), str.end());
	return str;
}
remove space in string c++
string removeSpaces(string str)
{
    stringstream s(str);
    string temp;
    str = "";
    while (getline(s, temp, ' ')) {
        str = str + temp;
    }
    return str;
}
//Input: Ha Noi Viet Nam
//Output: HaNoiVietNam




Cpp

Related
ray sphere intersection equation Code Example ray sphere intersection equation Code Example
hello world in c++ Code Example hello world in c++ Code Example
draw rectangle opencv c++ Code Example draw rectangle opencv c++ Code Example
Header for INT_MIN Code Example Header for INT_MIN Code Example
how to compare two char* in c++ Code Example how to compare two char* in c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8