I'm having serious problem with the following code:
unsigned char code * Progtxtstring_ENG[] = { "PROGRAM", "SYSTEM" }; unsigned char code * pMenu; //User selected English pMenu = Progtxtstring_ENG; //Why doesn't this work, it just get garbage out: printf("%s",pMenu[0]); // This line below works printf("%s",Progtxtstring_SWE[0])
Progtxtstring_ENG is an array of pointers; pMenu is just a single pointer. What do you need to do if you want to extract a single element from an array...?
I want to use the pMenu just as I use the Progtxtstring_ENG. I want to switch between arrays of pointers so I can point to different language. Maybe this will explain better:
unsigned char code * Progtxtstring_SWE[] = { "Program", "Tank tryck" }; unsigned char code * Progtxtstring_ENG[] = { "Program", "Tank Pressure" }; //I want an pointer to the array of pointers unsigned char code * pMenu; //User selected Swedish. (Not shown) pMenu = Progtxtstring_SWE; // Here I'm trying to print "Tank Tryck" printf("%s",pMenu[1]); // This line Prints "Tank Tryck" printf("%s",Progtxtstring_SWE[1])
Hmmmm I guess I need an char **ptr to access the array of pointers. It's clearing up a bit...
perhaps re-writing the definitions very slightly might help:
char *pChar
char* pChar
View all questions in Keil forum