1、陣列的本質:陣列的陣列
3、陣列與指標的關係:沒有任何關係!指標就是指標,陣列就是陣列。借用《征服c指標》這本書的一句話:只有在宣告語句中,才表達陣列的含義,在表示式中,與陣列無關!
4、**示例:
//一維陣列與指標的關係
void one_dimensional_array();
int *pa = array;
int (*pb)[3] =&array;
printf
("array is %p,value is %d. \n",array,*array);
//11
printf
("*pa is %p,value is %d. \n",pa,*pa);
//11
printf
("*(pa+1) is %p,value is %d. \n\n",pa+
1,*(pa+
1));
//22
printf
("**pb is %p,value is %d. \n",pb,**pb);
//11
printf
("**(pb+1) is %p,value is %d. \n",(pb+
1),**(pb+
1));
//越界
printf
("*(*pb+1) is %p,value is %d. \n",*pb+
1,*(*pb+
1));
//22 }
//二維陣列與指標關係
void second_dimensional_array(),
};int (*pa)[3] = array;
int (*pb)[2][3] = &array;
int (*pc) = array[0];
int (*pd)[3] = &array[0];
int pe = array[0][0];
int (*pf) = &array[0][0];
printf
("array is %p,value is %d. \n",array,**array);
//11
printf
("**pa is %p,value is %d. \n",pa,**pa);
//11
printf
("**(pa+1) is %p,value is %d. \n",pa+
1,**(pa+
1));
//21
printf
("*(*pa+1) is %p,value is %d. \n\n",(*pa+
1),*(*pa+
1));
//12
printf
("***pb is %p,value is %d. \n",**pb,***pb);
//11
printf
("***(pb+1) is %p,value is %d. \n",**(pb+
1),***(pb+
1));
//越界
printf
("**(*pb+1) is %p,value is %d. \n",*(*pb+
1),**(*pb+
1));
//21
printf
("*(**pb+1) is %p,value is %d. \n\n",(**pb+
1),*(**pb+
1));
//12
printf
("*pc is %p,value is %d. \n",pc,*pc);
//11
printf
("*(pc+1) is %p,value is %d. \n\n",pc+
1,*(pc+
1));
//12
printf
("*pd is %p,value is %d. \n",pd,**pd);
//11
printf
("**(pd+1) is %p,value is %d. \n",*(pd+
1),**(pd+
1));
//21
printf
("*(*pd+1) is %p,value is %d. \n\n",(*pd+
1),*(*pd+
1));
//12
printf("pe's value is %d.\n",pe); //11
printf
("*pf is %p,value is %d. \n",pf,*pf);
//11 }
//三維陣列與指標關係
void three_dimensional_array(),,},
,,}};
int (*pa)[3][4] = array;
int (*pb)[2][3][4]= &array;
int (*pc)[4] = array[0];
int (*pd)[3][4] = &array[0];
int (*pe) = array[0][0];
int (*pf)[4] = &array[0][0];
printf
("ary is %p,value is %d. \n",array,***array);
printf
("*pa is %p,value is %d. \n",pa,***pa);
printf
("*pb is %p,value is %d. \n",pb,****pb);
printf
("*pc is %p,value is %d. \n",pc,**pc);
printf
("*pd is %p,value is %d. \n",pd,***pd);
printf
("*pe is %p,value is %d. \n",pe,*pe);
printf
("*pf is %p,value is %d. \n",pf,**pf); }
指標與陣列,指標陣列 陣列指標
int a 10 print n a p,a p a,a print n a 1 p,a 1 p a 1,a 1 a做乙個指標,步長為4,指向乙個元素,a做乙個指標,步長為40,指向乙個維陣列 int b 3 4 print n b p,b p,b p b,b,b print n b 1 p,b 1...
指標陣列與陣列指標
1.指標陣列 指標陣列中每乙個元素都是乙個指標,也既是存放字串的首位址。所以指標陣列適合處理若干個長度不等的字串。定義的一般形式為 型別說明符 指標陣列名 陣列長度 例如 int p 3 宣告乙個陣列,指標陣列p,由3個int型別指標變數元素組成 從運算子的優先順序分析,由於 的優先順序大於 所以p...
指標陣列與陣列指標
呵呵,實在是厭倦了繞口的解釋。指標陣列,故名思義,就是指標的陣列,陣列的元素是指標 陣列指標,同樣,就是直想陣列的指標。簡單舉例說明 int p 2 首先宣告了乙個陣列,陣列的元素是int型的指標。int p 2 宣告了乙個指標,指向了乙個有兩個int元素的陣列。其實這兩種寫法主要是因為運算子的優先...