[ROOT]

From: Wolf (was@ucsd.edu)
Date: Mon Jul 26 2004 - 23:26:31 MEST


Hi there,

I am trying to remove a "," from a number in character format (e.g. 1,234) using the following code.

char *word1c = new char[20];
string word1s = word1c;

if(word1s.find(",")!=string::npos){
     int m = word1s.find(",");
     if(m!=-1){ cout<<word1s; }
     word1s.Remove(m,1);
     word1c = word1s.c_str();
}

First of all, when I write out word1s inside the if{} statement, it prints me also all the lines which do not contain a ",". Any suggestions why this happens?

Secondly, I get the following error message:

Error: Can't call string::Remove(m,1) in current scope ...
Possible candidates are...
filename    line:size busy function type and name (in string)
Error: Symbol word1s is not defined in current scope
Error: Failed to evaluate word1s.Remove(m,1) Possible candidates are...
filename    line:size busy function type and name
*** Interpreter error recovered ***

Any suggestions?

Thanks very much. 

Wolf



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:09 MET