The correct way to define and initialize your array is
char Lookup[][3] = {"00", "01", "02", "03", "04", "05", "06", "07", "08"};
Each element of the array Lookup
is itself another array of 3 bytes. Counting with the zero terminator, that’s enough space for strings 2 chars long.
The number of elements in the array is available with the expression sizeof Lookup / sizeof *Lookup
, as in
int k;
for (k = 0; k < sizeof Lookup / sizeof *Lookup; k++) {
printf("element at index %d: %s\n", k, Lookup[k]);
}
3
solved c – What is a correct way of defining array? [closed]