How do you point to a const char array with the name in an array?

dfansler's Avatar, Join Date: Aug 2012
Newbie Member
I am doing some work with a LCD graphic display and a microcontroller. I have defined the alphabet in a series of constant char arrays that tell me what bits to turn on or off to display that character - ie. for '0' (0x30)

const char CS22PT_0x30[122] ={18,40,
0x00,0x00,0x00,0x00,x00,0x10, etc.........
The first two numbers are the x and y size of the character. I call this array by
char far *name
name = &CS22PT_0x30;

And this works. As long as I know ahead of time what the name of the const char array I am calling is.

So the next step was to take a char array containing the string I want to display and determine which const char array to call on the fly rather than hard coding it in.

What I have so far is an array predfined as
char text_1[] = {"Night's Beautiful Daughter"};

I set a pointer to the array
char *t_to_d;
t_to_d = &text_1[0];

call a function that uses that pointer and the name of the font to use

font_22 was previously defined as
char font_22[]={"CS22PT"};

the write_text fucntion then converts (starting with the first character of text_1[0]) into a hex value that is cat onto the font name. ie Since the first character in text_1 is 'N' which is 0x4e in hex, I get an array that contains CS22PT_0x4e

FINALLY I can ask the question!!
How do I use the string "CS22PT_0x4e" in the array to point to the const char CS22PT_0x4e so I can get the data out of const char CS22PT_0x4e?

debugEnthu's Avatar
Go4Expert Member

Which language are u using??/

In case you are using C++ you canuse STL map containers

map<unsigned int, char *> mymap.

Here key (unsigned int) would be hex representation of character...n your example - 0x4e
dfansler's Avatar, Join Date: Aug 2012
Newbie Member
opps - I am writing in C.