1 Replies - 1959 Views - Last Post: 29 October 2006 - 06:52 PM Rate Topic: -----

#1 megan09  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 19-October 06

Taking spaces out of multi-word strings

Posted 29 October 2006 - 06:49 PM

[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;



}

Is This A Good Question/Topic? 0
  • +

Replies To: Taking spaces out of multi-word strings

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Taking spaces out of multi-word strings

Posted 29 October 2006 - 06:52 PM

string remove_spaces();
What is this supposed to represent? Is it a string declaration? A call to a function? A function prototype? After that declaration, you are then streating it like a string...trying to append to it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1