how to ignore space in string in c++
#include <iostream>
std::string IgnoreWhitespace(std::string str)
{
for(int i = 0; i < str.length(); i++)
{
if(str[i] == ' ') str.erase(i, 1);
}
return str;
}
int main()
{
std::string str = "W h i t e s p a c e";
std::cout << IgnoreWhitespace(str); // Output = Whitespace
return 0;
}