|
[I'm trying to create a function which removes the spaces from a multi-word input string. When I ran my program I got the following errors: "warning C4018: '<=' : signed/unsigned mismatch" and "error C2784: 'std::basic_string<_Elem,_Traits,_Alloc> std::operator +(const std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem)' : could not deduce template argument for 'const std::basic_string<_Elem,_Traits,_Ax> &' from 'overloaded-function'". What am I doing wrong?? Here's my code]
#include <iostream> using namespace std; #include <string> #include <sstream>
int main () { string s; cout << "Enter a string: " << endl; getline (cin, s); string remove_spaces();
int i=1; while (i<=s.length()); { string t(s.substr(i,s.find(" "))); remove_spaces = remove_spaces + t; { cout << remove_spaces << endl;
return 0;
}
|