When is pointer to array useful?

前端 未结 9 1884
天涯浪人
天涯浪人 2020-12-30 09:18

I can declare:

int (*ap)[N];

So ap is pointer to int array of size N. Why is this ever useful? If I pass it to function, what usefu

9条回答
  •  爱一瞬间的悲伤
    2020-12-30 09:51

    This will probably careen off into subjective/argumentative, but...

    In my opinion, pointers to arrays are in the language because they fell into the language. There are pointers to every other declarable data type, so these are here too. I've never seen anyone get really useful work out of them. Hypothetically, they allow a prototype that demands an array and not a pointer to the element, but ...

提交回复
热议问题