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

后端 未结 5 1501
醉酒成梦
醉酒成梦 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:32

    Not looked in too much detail but I think the author is relying upon c laying out a 2d string array like this:

    key, value, key, value, key, value in contiguous memory. Then traversing this array as a 1d array of strings p = (char **)dic;

    This is one of the beauties and potential problems with C - it has lots of low level power but the you have protect yourself with decent code to prevent side effects.

提交回复
热议问题