Hi,
I am having a problem with a piece of code. Its a static pointer char array declared as follows.
Code:
static char *codagemc[2787] = { "urA", "xfs", "ypy", "unk", "xdw", "yoz", "pDA", "uls", "pBk", "eBA",
...... 2787 elements }
The array is a pointer to characters. So when I print the array in gdb I get the following values
Code:
codagemc =
{0xd5d000 "urA", 0xd5d004 "xfs", 0xd5d008 "ypy", 0xd5d00c "unk", 0xd5d010 "xdw", 0xd5d014 "yoz", 0xd5d018 "pDA", 0xd5d01c "uls", 0xd5d020 "pBk", 0xd5d024 "eBA",
........ 2787 elements}
So its clear addresses are stored but I can't seem to make out the relationship between the addresses & the hard-coded characters.
Intriguingly when I print out codagemc[0] I get 0xd5d000 "urA" . But when I print out *codagemc[0] I get 117 "u" (the first character of the string "urA" that is defined in static array. This particular property is true for all the values in the above pointer array). My point is dereferencing the address (oxd5d000 "urA") gives me the first character . I can't make out the relationship between the hex values, the string "urA" & the character "u".
Also I have never seen addresses hard-coded in the array. Since the array is declared as static it should reside in the data/text segment of the program so hard-coding is fine I guess.
The above array is used as a lookup table in a barcode generator. The idea is to map codewords (929 codewords * 3 modes = 2787) to alphabets. I would elaborate more if you desire so.
I would appreciate any help on this problem. Thanks for your time.