Array of strings difficulty

I'm using something similar to what is below in my code (clipped from the Arduino.cc reference page).
I'm new to C and the char arrays and pointers really throw me.

The only thing I'm doing different is the println function is in a separate function, not the "loop" function. I'm guessing this is a scope issue, but I'm not sure how scope is applied when it comes to pointers, rather arrays of pointers. I'm just trying to set up some error messages and wanted to declare the messages to be used globally. Can that be done?

char* myStrings[]={"This is string 1", "This is string 2", "This is string 3",
"This is string 4", "This is string 5","This is string 6"};

void setup(){
Serial.begin(9600);
}

void loop(){
for (int i = 0; i < 6; i++){
Serial.println(myStrings*);*

  • delay(500);*
  • }*
    }
    [/quote]

Hi chipwitch

You need to add an index to your array reference in the println statement, at least.

Try ...

for (int i = 0; i < 6; i++){
   Serial.println(myStrings[i]);
   delay(500);
   }

Does this help?

Ray

Well, sort of!

Now I'm embarrassed. I actually had the index in my code, but didn't notice that the example I showed did not! So, I went back and looked at it, deleted the index from my code to match the "official arduino example." That didn't help either. Then I noticed I spelled my variable "errsring" instead of errstring. Dropped the "t".

Thank you... you got me there.
:slight_smile: