I try to run this example code on my Arduino, but since Arduino IDE version 1.0 it doesn't work no more. The example is mainly copied and stripped down from this example.
void setup() {
Serial.begin(9600);
}
void loop() {
// toUpperCase() changes all letters to upper case:
String stringOne = "test";
Serial.println(stringOne);
stringOne = (stringOne.toUpperCase());
Serial.println(stringOne);
// do nothing while true:
while(true);
}
Error message:
StringCaseChanges.cpp: In function ‘void loop()’: StringCaseChanges.cpp:12:39: error: no match for ‘operator=’ in ‘stringOne = stringOne.String::toUpperCase()’ /usr/share/arduino/hardware/arduino/cores/arduino/WString.h:83:11: note: candidates are: String& String::operator=(const String&) /usr/share/arduino/hardware/arduino/cores/arduino/WString.h:84:11: note: String& String::operator=(const char*)
On the help page one can see that:
As of 1.0, toUpperCase() modifies the string in place rather than returning a new one.
However I don't see the reason why the example code doesn't compile.
Can you help me?
Thank you!
//EDIT
OK, this one works: void setup() { Serial.begin(9600); }
void loop() {
// toUpperCase() changes all letters to upper case:
String stringOne = "test";
Serial.println(stringOne);
stringOne.toUpperCase();
Serial.println(stringOne);
// do nothing while true:
while(true);
}
However, the help page should be changed!