Is it bad practice to use multi-dimensional arrays in C/C++?

前端 未结 9 885
北海茫月
北海茫月 2021-02-07 04:46

Some programmers seem to violently hate them, while others seem to think they\'re fine. I know that anything that can be done to a multi-dimensional array can also be done to a

9条回答
  •  走了就别回头了
    2021-02-07 05:17

    I know that anything that can be done to a multi-dimensional array can also be done to a regular array

    I do not think that's entirely accurate. We'll need an array of pointers to store something as basic as a list of names and then sorting it. Or pointers to pointers to store a variable length string and then a list of such strings. As the original questions mentions only arrays per se, can't see how problems like these can be done with equal ease in a regular array. Please consider not just storing the strings in a 1-D array (using some sort of separator maybe) but also performing operations such as sorting.

提交回复
热议问题