See: https: //zh.cppreference.com/w/cpp/algorithm/remove
std :: remove does not change the length of the input vector / string of. The procedure is equivalent to the removal of specified character (with string, for example), the remaining characters move forward on. Behind the original character and consistency. See the results of sample program
#include <algorithm> #include <string> #include <iostream> #include <cctype> int main() { std::string str1 = "Text with some spaces 123"; std::remove(str1.begin(), str1.end(), ' '); std::cout << str1 << '\n'; }
Output:
Textwithsomespaceses 123
Note the last six.