Hacker News new | ask | show | jobs
by THBC 656 days ago
”every pointer is simply adding a dimension to the data.”

No, it’s not. The concept of having a pointer to a pointer has nothing to do with the concept of dimensionality.

You must be thinking of lists of lists (of lists…), which can be implemented using pointers. The dimensionality, however, comes from the structure of the list, not from the pointers.

2 comments

Right. -ish. A two dimensional array can be modeled as an array of pointers to one dimensional arrays or as one pointer to a two dimensional array. Both have use cases. It's probably a right of passage for someone new to the C language to understand that difference (I learnt C as a teenager and it took me some time, months, to comprehend all the different permutations of pointers and square brackets).
I guess you skimmed over: “Which is one way to interpret things”

I’m certainly not thinking of a list-of-lists. In actuality, pointers ARE dimensionality, regardless of the intended use.

I’m not going to spell that out further. If you can’t see that, then you’ve got some work to do if you’re maintaining a C codebase.