I've a simple sketch which should convert a basic string into a char Array. EasyPeasy Lemon pie and thx god or StarTrek that arduino support the string.toCharArray() method.
However, I receive weird error and sit here with no clue what is wrong.
void setup(){
Serial.begin(9600);
}
String input = "TEST";
int input_length = input.length()+1;
char splitter[input_length];
input.toCharArray(splitter, input_length);
void loop()
{
if(Serial.available() > 0)
{
input = Serial.readString();
input.toUpperCase();
}
Serial.println(input);
delay(500);
}
Error Code
sketch_dec05b:10: error: array bound is not an integer constant before ']' token
char splitter[input_length];
^
sketch_dec05b:11: error: 'input' does not name a type
input.toCharArray(splitter, input_length);
^
exit status 1
array bound is not an integer constant before ']' token
So what the heck did I wrong ???