我需要一个指向静态二维数组的指针.这是怎么做到的?
static uint8_t l_matrix[10][20];
void test(){
uint8_t **matrix_ptr = l_matrix; //wrong idea
}
Run Code Online (Sandbox Code Playgroud)
我得到各种错误,如:
这段代码:
extern void *malloc(unsigned int);
struct Box {
int x, y ,w, h;
};
struct Wall {
char color[15];
struct Box *boxes[20];
};
int main(int argc, const char *argv[])
{
struct Wall *mywall = malloc(sizeof(struct Wall));
struct Box *myboxes[] = mywall->boxes;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
invalid initializer在第14行给出了错误.我想要做的是获取结构指针数组的副本,它们位于不同的结构中.