What's the difference between arrays of arrays and multidimensional arrays?

前端 未结 5 749
无人及你
无人及你 2020-12-20 17:34

I had a language-agnostic discussion with someone in the C++ chat and he said that arrays of arrays and multidimensional arrays are two things.

But from what I lear

5条回答
  •  伪装坚强ぢ
    2020-12-20 18:04

    C does not have multidimensional arrays but C have arrays of arrays.

    In the Standard, the wording multidimensional array is used but C multidimensional arrays are in reality arrays of arrays. From Kernighan & Ritchie:

    "In C, a two-dimensional array is really a one-dimensional array, each of whose elements is an array."

    Some languages support multidimensional arrays as first class types. The "Expert C Programming" book shows the example of Ada which supports both arrays of arrays and multidimensional arrays.

提交回复
热议问题