Write a program that removes all spaces from the given input. Ex: If the input is: Hello my name is John. the output is: HellomynameisJohn. Your program must define and call the following function. The function should return a string representing the input string without spaces.string RemoveSpaces(string userString) #include <iostream>#include <algorithm>using namespace std; string removeSpaces(string str) { str.erase(remove(str.begin(), str.end(), ' '), str.end()); return str; } /* Define your function here */ int main() {string str; str = removeSpaces(str); cout << str << endl; /* Type your code here. Your code must call the function. */ return 0;} Please help me with this problem using c++.
Write a
Ex: If the input is:
Hello my name is John.
the output is:
HellomynameisJohn.
Your program must define and call the following function. The function should return a string representing the input string without spaces.
string RemoveSpaces(string userString)
#include <iostream>
#include <algorithm>
using namespace std;
string removeSpaces(string str)
{
str.erase(remove(str.begin(), str.end(), ' '), str.end());
return str;
}
/* Define your function here */
int main() {
string str;
str = removeSpaces(str);
cout << str << endl;
/* Type your code here. Your code must call the function. */
return 0;
}
Please help me with this problem using c++.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images