Change some char in char array

Hi everybady,

i have problem with some code

char ONE[1];
char MENU[][maxItemSize] ={"Date","Time","Alarm","Format","Zone","Daylight","BACK"};
.
..
...

strcpy(ONE,"Proba");

I want change MENU[1] with ONE //MENU[1]=Time and i want MENU[1]=Proba

///

when ONE is string i will use ONE.toCharArray(MENU[2], ONE.length()+1); and everything is work but with ONE=char i dont know.

Somebody can help me, thanks.

char ONE[1];

How many characters can this array hold ?

strcpy(ONE,"Proba");

How many characters are you copying to it ?

ONE have One character

strcpy(ONE,"P"); // this is only example "P" or "Proba"

Brkic:
ONE have One character

strcpy(ONE,"P"); // this is only example "P" or "Proba"

Even "P" is actually 2 characters. It's the 'P' and also the null terminator '\0'

You need ONE to have the same number of characters as the second dimension of MENU. So use MaxItemSize there.

OK, I will change that

char ONE[2];
char MENU[][maxItemSize] ={"Date","Time","Alarm","Format","Zone","Daylight","BACK"};
.
..
...

strcpy(ONE,"P");

I want change MENU[1] with ONE //MENU[1]=Time and i want MENU[1]=P

Brkic:
I want change MENU[1] with ONE //MENU[1]=Time and i want MENU[1]=P

I don't understand what you mean by this.

Maybe:

strcpy(MENU[1], "P");

or

strcpy(MENU[1], ONE);

This is a code when ONE is string

char MENU[][maxItemSize] ={"Date","Time","Alarm","Format","Zone","Daylight","BACK"};
String ONE;

void niz()
{
ONE="Proba";
ONE.toCharArray(menu[1], amp.length()+1);
}

and that code is work OK,

now ONE is char,how to replace value in a MENU

char ONE[6];

Thanks it worked !! :slight_smile:

strcpy(MENU[1], ONE);

Brkic:
Thanks it worked !! :slight_smile:

strcpy(MENU[1], ONE);

Yeah, it's the same as this one that you were already using:

strcpy(ONE,"P");

I guess that's why it was confusing. You seemed to already understand the answer.