I found this function toCharArray() that converts string to char and tried using it in my code
Code:
String MyString = "Arduino";
char ch[20];
MyString.toCharArray(ch,20);
void setup() {
Serial.begin(9600);
}
void loop() {
}
I get this error message:
Arduino: 1.8.8 (Windows 10), Board: "Arduino/Genuino Uno"
sketch_jan13a:3:1: error: 'MyString' does not name a type
MyString.toCharArray(ch,20);
^
exit status 1
'MyString' does not name a type
Can you please help me find out where I've got it wrong.
thanks!