sketch_mar16a.ino: In function 'String stripMyStr(String)':
sketch_mar16a:15: error: call of overloaded 'replace(char&, const char [1])' is ambiguous
/Applications/Arduino_1.0.4.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:164: note: candidates are: void String::replace(char, char) <near match>
/Applications/Arduino_1.0.4.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:165: note: void String::replace(const String&, const String&) <near match>
The error message is basically telling you what you need. This compiles:
//declared at the top of program
const char stripChars [6] PROGMEM = "{}DIT";
//Sanity call to function
String striped = stripMyStr("{A}AIATADA");
//function
String stripMyStr(String strToStrip)
{
for (int i = 0; i < 5; ++i)
{
char myChar = pgm_read_byte (stripChars + i);
strToStrip.replace(String (myChar), "");
}
return strToStrip;
}
void setup ()
{
Serial.begin (115200);
Serial.print (stripMyStr ("{A}AIATADA"));
} // end of setup
void loop () { }
Please note that in versions of the IDE up to and including 1.0.3, the
String library has bugs as discussed
here and
here.
In particular, the dynamic memory allocation used by the String class may fail and cause random crashes.
I recommend reworking your code to manage without String. Use C-style strings instead (strcpy, strcat, strcmp, etc.), as described
here for example.
Alternatively, install the fix described here:
Fixing String CrashesPreferably upgrade your IDE to version 1.0.4
or above at:
http://arduino.cc/en/Main/Software