Hello,
I had posted on this topic before, but it had a different tack. My problem is (simplified a teeny bit for the forum) is that I have three strings of varying length. I want to reference them in an array, so that I can reference the nth string randomly
I have defined the three strings as separate variables. Then create an array of pointers to the individual strings. Thus, when I want to use (print) a string, I can index the pointer array.
Clear as mud? I hope not. I am sure that I am doing mutiple things wrong in the code below; mainly because it won't compile. Can you take a look and explain where my misunderstanding lies?
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
char MoveString_0[] ="#0P1500#1P1500#2P1000#3P570#4P1500#5P2400#6P510#8P1500#9P1500#10P1500#11P1400T1000";
char MoveString_1[] ="#2P1100";
char MoveString_2[] ="#0P2000 #1P1100 T100";
char* MoveCommand[] =
{
(&MoveString_0) ,
(&MoveString_1) ,
(&MoveString_2)
};
Serial.println( *MoveCommand[1] );
while (-1){};
}
The error I am getting is:
MoveCommandTest:17: error: cannot convert 'char (*)[83]' to 'char*' in initialization