I need a pointer to a static 2-dimensional array. How is this done?
static uint8_t l_matrix[10][20];
void test(){
uint8_t **matrix_ptr = l_matrix; //wron
The basic syntax of initializing pointer that points to multidimentional array is
type (*pointer)[1st dimension size][2nd dimension size][..] = &array_name
The the basic syntax for calling it is
(*pointer_name)[1st index][2nd index][...]
Here is a example:
#include
#include
#include
int main() {
// The multidimentional array...
char balance[5][100] = {
"Subham",
"Messi"
};
char (*p)[5][100] = &balance; // Pointer initialization...
printf("%s\n",(*p)[0]); // Calling...
printf("%s\n",(*p)[1]); // Calling...
return 0;
}
Output is:
Subham
Messi
It worked...