二維數(shù)組

typedef?int(INT10)[10];
main()
{
int?array[10] = { 0,1,2,3,4,5,6,7,8,9 };
int?other[2][5] = { 0,1,2,3,4,5,6,7,8,9 };
int(*parray)[10] = &array;
printf("%p\r\n", array + 1);//首 元素 地址 ?????effa48 + 1*type(4) = effa4b
printf("%p\r\n", other + 1);//首 數(shù)組類型 地址 ?effa18 + 1*type(4)*5 = effa48
int* parray[10] = &array;//數(shù)組指針
}
·二維數(shù)組在內(nèi)存呈線性排列
·二維數(shù)組第一維度存儲(chǔ)的是數(shù)組指針

typedef?int(INT10)[10];
void?Foo(int?*array)
{
}
數(shù)組指針
main()
{
int?array[10] = { 0,1,2,3,4,5,6,7,8,9 };
int?other[2][10] = { 0,1,2,3,4,5,6,7,8,9 };
Foo(array);//array 常量 指針(int* const) ?
Foo(&array);//&array 常量 數(shù)組指針(int(*)[10])
Foo(other);//other 常量 數(shù)組指針 (int(*)[10]) other指向一個(gè)長(zhǎng)度為10的數(shù)組的指針
Foo(&other);//&other 常量 數(shù)組指針 (int(*)[2][10])
int(*parray)[10] = &array;//定義了一個(gè)數(shù)組指針指向數(shù)組array
}
***************************************************************************************
void?Foo(int?*array)
{
}
main()
{
int?array[10] = { 0,1,2,3,4,5,6,7,8,9 };
int?other[2][10] = { 0,1,2,3,4,5,6,7,8,9 };
Foo(&array);
}
函數(shù)Foo的參數(shù)類型為int*和傳入的參數(shù)&array的類型int(*)[10]不匹配,會(huì)報(bào)錯(cuò),如下:

可改為:
void?Foo(int?*array[10])
{
}
指針數(shù)組:用來(lái)存放指針的數(shù)組
char?*keys[100] = { "wo","zei","tm","shuai"?};//存放100個(gè)指針
