Access Array's

Hi together.

I'm new on Arduino :wink:

I want to fill a char Array like:

char myArray = {"hello1","hello2","hello3"}

but when i want to write the second place in the array:

Serial.write(myArray[2]);

so they comes the letter "e" (the second letter in the Array)

I want to set a pointer of the array place and give the name out.

Sorry, but i hope you understand me :o

thanks
pat

Adding the minimum to make this an actual sketch:

char myArray[] = {"hello1","hello2","hello3"};


void setup() {
  Serial.begin(9600);
  Serial.write(myArray[2]);
}


void loop() {}

Error:

sketch_dec10a:1: error: too many initializers for 'char []'
 char myArray[] = {"hello1","hello2","hello3"};
                                             ^
exit status 1
too many initializers for 'char []'

Perhaps you meant:

// Array of three character pointers:
char *myArray[] = {"hello1","hello2","hello3"};

or

// Array of three character arrays:
char myArray[7][] = {"hello1","hello2","hello3"};

but when i want to write the second place in the array:

Serial.write(myArray[2]);

That is the THIRD place in the array. The index always starts at 0 so 0, 1, 2... third place.

I want to set a pointer of the array place and give the name out.

Do you mean you want to have

Serial.print(myArray[2]);

display "hello3"?

Hi

thanks i will try!

pat