char * p1[3]二维数组名和二维数组指针做函数参数

#include
#include
#include

int myPrintf6(char **p,int *dep,int * len){
int lenth = *len;
int depth = *dep;
printf(“-----------------\n”);
printf(“%s\n”,func);
for(int i=0; i for(int j=0; j printf(“%d\n”,p[i][j]);
}
}
return 0;
}

int myPrintf7(char *(*p)[3],int *dep,int * len){
int lenth = *len;
int depth = *dep;
printf(“-----------------\n”);
printf(“%s\n”,func);
for(int i=0; i for(int j=0; j printf(“%d\n”,(*p)[i][j]);
}
}
return 0;
}

int main() {

int len2 = 3;
int dep2 = 2;


char * p1[3] = {"aaa","bbb"};
myPrintf6(p1,&dep2,&len2);//p把二维数组首地址拷贝给形参
myPrintf7(&p1,&dep2,&len2);//&p把二维数组地址拷贝给形参

return 0;

}

你可能感兴趣的:(c)