Array of pointers to multidimensional arrays

后端 未结 3 1902
长发绾君心
长发绾君心 2021-02-10 19:38

i have some bidimensional arrays like:

int shape1[3][5] =  {1,0,0,
             1,0,0,
             1,0,0,
             1,0,0,
             1,0,0};
int shape2[3]         


        
3条回答
  •  走了就别回头了
    2021-02-10 20:16

    Updated Fixed type. Thanks j_radom_hacker for bringing this to my attention!

    [EDIT: Actually the type here was not correct -- see Robert S. Barnes' answer for the correct type to use.]

    Figure out the type of shape1 and shape2 first:

    typedef int (*shape_array_t)[5];
    

    Now use this:

    shape_array_t sat[] = { shape1, shape2 };
    

提交回复
热议问题