In C/C++, is char* arrayName[][] a pointer to a pointer to a pointer OR a pointer to a pointer?

后端 未结 5 1472
醉酒成梦
醉酒成梦 2020-12-01 10:19

I understood multi-dimensional arrays as pointers to pointers, but perhaps I am wrong?

For example, I though:

char * var = char var[]

5条回答
  •  有刺的猬
    2020-12-01 10:29

    You need to refer to 'right left rule'. Alternatively you can deciper most of the C-ish declarations at here

    So,

    char *p[2][3] is parsed as

    p is an array of 2 elements where each element is an array of 3 elements, such that each element is a pointer to a character.([] binds stronger than *)

    char (*p)[2][3] is parsed as

    "p is a pointer to a 2 element char array where each element is a char array of 3 elements." (parenthesis binds the strongest)

提交回复
热议问题