指针多维数组的数组 [英] Array of pointers to multidimensional arrays

查看:109
本文介绍了指针多维数组的数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些二维阵列,如:

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][5] =  {0,0,0,
    		 0,0,0,
    		 0,1,1,
    		 1,1,0,
    		 0,1,0};

等。

我怎样才能让指针数组那些?

How can i make an array of pointers to those?

我尝试以下,但他们不工作(的警告:初始化从兼容的指针类型的):

I tried the following, but they don't work (warning: initialization from incompatible pointer type):

int *shapes[]=  {&shape1,&shape2};

int *shapes[]=  {shape1,shape2};

int **shapes[]= {&shape1,shape2};

任何帮助吗?

推荐答案

更新固定类型。感谢 j_radom_hacker 提出这个对我的关注!

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

图出的类型 shape1 shape2 第一:

typedef int (*shape_array_t)[5];

现在使用:

shape_array_t sat[] = { shape1, shape2 };

这篇关于指针多维数组的数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆