如何打印具有两个取消引用的3d数组的元素。我认为它需要类似于3取消引用printf("%c",*(*(*(a+0)+1)+1));的东西。有一个理解的危机。
int main()
{
char a[2][3][3] = {'a','b','c','d','e','f','g',
'h','i','j','k','l','m'};
printf("%s ", **a);
getchar();
return 0;
} 发布于 2018-10-26 19:24:33
为指定的%s提供的参数应为指针。对于’%s,printfuses the pointer to fet characters from memory. Therefore, for a three-dimensional array, applying two*to the name results in the correct type, a pointer tochar`.
对于%c,参数应该是具有字符值的int。将三个*应用于数组可以实现这一点。
注意:尽管**a为%s提供了正确的类型,但参数应该指向以null结尾的一维字符串中的一个字符。允许字符跨数组维度继续是不可靠的。
https://stackoverflow.com/questions/53002016
复制相似问题