CPP:
int **p = new int*[3];
// int *看成数据类型,
// 再看 int *p = new int[3];
// 相当于 int * (*) p = new int (*)[3];
// 两边都加了一个*
for ( int i = 0; i < 3; i++ )
{
p[i] = new int[4];
for (int j = 0; j < 4; j++)
{
p[i][j] = .....//自己赋值
}
}
C:
char **p = (char **)malloc(sizeof(char*) * 3);
// 对比这个不难理解char *p = (char *)malloc(sizeof(char*) * 3);
//又是两边多了一个*
int i = 0;
for (i = 0;i < 3;i++)
{
p[i] = (char *)malloc(sizeof(char) * 4);
}