1. 二维数组
TYPE array[row][column];
在定义时row可以不指定,但column必须指定。例如:
int arr1[3][2]={{1,2},{3,4},{5,6}};
等价于:
int arr1[][2]={{1,2},{3,4},{5,6}};
2.指向二维数组的指针:
TYPE (*parray)[column];
在定义时,column必须指定,例如定义一个指向上面定义的二维数组的arr1[3][2]的指针:
int (*parr1)[2];
parr1=arr1;
3.指针数组:
TYPE *array[num];
例如定义一个指针数组,包含三个int的指针:
int *parr2[3];
int a,b,c;
parr2[0]=&a;
parr2[1]=&b;
parr2[2]=&c;
4.指向二维数组的指针数组:
TYPE (*parray[num])[column];
其中column为二维数组的维度。num为指针的个数,定义时如果直接赋值的话,可以不指定num的大小。
例如定义一个指针arr1的指针数组,数组的大小为5:
int (*parr1[5])[2];
parr1[0]=arr1;
printf("%d",parr1[0][2][1]); // 输出为:6
另外一个例子:
static const char _keyboard_lower[4][10]=
{
{'q','w','e','r','t','y','u','i','o','p'},
{'a','s','d','f','g','h','j','k','l'},
{'z','x','c','v','b','n','m',LITE_KEYSYM_BACKSPACE},
{LITE_KEYSYM_INPUT_METHOD,LITE_KEYSYM_INPUT_MODE,' ',LITE_KEYSYM_CAPS_LOCK,LITE_KEYSYM_ENTER},
};
static const char _keyboard_upper[4][10]=
{
{'Q','W','E','R','T','Y','U','I','O','P'},
{'A','S','D','F','G','H','J','K','L'},
{'Z','X','C','V','B','N','M',LITE_KEYSYM_BACKSPACE},
{LITE_KEYSYM_INPUT_METHOD,LITE_KEYSYM_INPUT_MODE,' ',LITE_KEYSYM_CAPS_LOCK,LITE_KEYSYM_ENTER},
};
static const char _keyboard_num[4][10]=
{
{'1','2','3','4','5','6','7','8','9','0'},
{'@','$','%','&','*','-','/','(',')'},
{'!','`',':',';',',','?','.',LITE_KEYSYM_BACKSPACE},
{LITE_KEYSYM_INPUT_METHOD,LITE_KEYSYM_INPUT_MODE,' ',LITE_KEYSYM_CAPS_LOCK,LITE_KEYSYM_ENTER},
};
static const char (*_keyboard_char[])[10]={
_keyboard_lower,
_keyboard_upper,
_keyboard_num,
};
{
{'q','w','e','r','t','y','u','i','o','p'},
{'a','s','d','f','g','h','j','k','l'},
{'z','x','c','v','b','n','m',LITE_KEYSYM_BACKSPACE},
{LITE_KEYSYM_INPUT_METHOD,LITE_KEYSYM_INPUT_MODE,' ',LITE_KEYSYM_CAPS_LOCK,LITE_KEYSYM_ENTER},
};
static const char _keyboard_upper[4][10]=
{
{'Q','W','E','R','T','Y','U','I','O','P'},
{'A','S','D','F','G','H','J','K','L'},
{'Z','X','C','V','B','N','M',LITE_KEYSYM_BACKSPACE},
{LITE_KEYSYM_INPUT_METHOD,LITE_KEYSYM_INPUT_MODE,' ',LITE_KEYSYM_CAPS_LOCK,LITE_KEYSYM_ENTER},
};
static const char _keyboard_num[4][10]=
{
{'1','2','3','4','5','6','7','8','9','0'},
{'@','$','%','&','*','-','/','(',')'},
{'!','`',':',';',',','?','.',LITE_KEYSYM_BACKSPACE},
{LITE_KEYSYM_INPUT_METHOD,LITE_KEYSYM_INPUT_MODE,' ',LITE_KEYSYM_CAPS_LOCK,LITE_KEYSYM_ENTER},
};
static const char (*_keyboard_char[])[10]={
_keyboard_lower,
_keyboard_upper,
_keyboard_num,
};