杨旭晨 提问:英雄哥好,为什么以下两段代码在打印指针数组时,p不需要星号解引用,但pmat需要星号解引用
1.
char a[]="abc";
char b[]="def";
char c[]="ghi";
char* p[3];
p[0]=a; //指向a的地址
p[1]=b; //指向b的地址
p[2]=c; //指向c的地址
for(int i=0;i<3;i++){
cout<<p[i];
}
2.
int mat[3][4]={
{1,2,3,4},
{5,6,7,8},
{9,10,11,12}
};
int* pmat[3];
pmat[0]=mat[0];
pmat[1]=mat[1];
pmat[2]=mat[2];
for(int i=0;i<3;i++){
for(int j=0;j<4;j++){
cout<<*(pmat[i]+j);
}
}
p[i] 代表的是 a 、b 、c 也就是字符串的首地址,可...