"SubMenu0[SubMenuActual]" give me wrong!

Good morning to everyone!

char *Menu[2];
char *SubMenu0[2];
int SubMenuActual;

Menu[0] = "Ajuste...";
SubMenu0[0] = "Relogio";
SubMenu0[1] = "Calendario";
SubMenu0[2] = "Iluminacao LCD";
Menu[1] = "Visualizacao";
Menu[2] = "Previsao";

void Escreve_LCD1(char *sTexto){
lcd.cursorTo(1,1);
lcd.printIn(sTexto);
}

void Escreve_LCD2(char *sTexto){
lcd.cursorTo(2,1);
lcd.printIn(sTexto);
}

Escreve_LCD1(SubMenu0[SubMenuActual]);
Escreve_LCD2(SubMenu0[SubMenuActual+1]);

when I do:

Serial.println(SubMenuActual);
Serial.println(SubMenu0[SubMenuActual]);
Serial.println(SubMenu0[SubMenuActual+1]);

I have the following...
0 //ok
Previsao //wrong
Calendario //ok

I don't understand how is possible that "SubMenu0[SubMenuActual]" give me "Previsao" instead "Relogio"... because I'm not renaming the string at anywhere else!!!

Please, if you have any idea, please don't hesitate to help me.
Sometimes I feel tired developing on Arduino.

Thanks on advance
Best regards

Pedro Ferrer

Menu is declared with two elements, but you're putting in three.
Ditto SubMenu.

Good morning Groove

Can you be more explicit?
Give me an example please.
How I have to do it correctly?

Thanks on advance
Best regards

Pedro Ferrer

What he's saying is that you have three menu items in each array, so at the beginning it needs to be:

char *Menu[3];
char *SubMenu0[3];
int SubMenuActual;

When you declare an array, you say how many things are in the array. You have three things in your array, which are Menu[0], Menu[1] and Menu[2]

Far simpler:

char* Menu[] = {"Ajuste...", "Visualizacao", "Previsao"};
char* SubMenu0[] = {"Relogio", "Calendario", "Iluminacao LCD"};

let the compiler do the hard work!

Good morning

Ok. I understand.
On VB, my arrays are 0 based. It means the if I put Menu(2), I'll have 3 elements.
Let's say that Arduino array is 1 based.

And my mistake, create all this confusion!?? Change strings!?

Please let me know how is possible this kind of strange behaviour.

Thanks on advance
Best regards
Pedro Ferrer

I don't know VB, but that doesn't sound quite right.
Old-style Basic used unity-origin, but most languages require you to declare the capacity of the array, not the highest index.
Yours failed because the imaginary Menu[2] was overwritten by SubMenu[0]

Thanks by your prompt help.
I'll check later at night.

Thanks once again
Best regards

Pedro Ferrer