I have a function like this:
void Menu_show(uint8_t count, char items[][UI_COLS + 1]);
where count is the length of the first dimension of the array items. I call this function in this way:
#define MAX_SIZE 4
char items[MAX_SIZE ][UI_COLS + 1];
for (uint8_t i = 0; i < MAX_SIZE ; i++) sprintf(items[i], "%u", i);
...
Menu_show(MAX_SIZE, items);
It works, but now I need to store a pointer to the first element of the array in my function.
My tougths:
- the first element is
items[0][0]
- its pointer is
&items[0][0]
- but now I have a pointer to a char, not to a bidimensional array
In fact, something like printf(items[3])
doesn't work in this way.
Then, I thought that the pointer to the first element of the second (fixed) dimension is &item[0]
but:
char *_items[UI_COLS + 1];
_items = &items[0];
gives an error:
assignment to expression with array type
I don't understand the right syntax to keep the bidimensional array usage when store the first location in a pointer.