Hacker News new | ask | show | jobs
by fsckboy 585 days ago

  int *foo[3]; // pointer to array of int
that's an array of 3 pointers to ints. if you pass foo as an argument you get a pointer to a pointer to an int (with knowledge if you can hang onto it that there are more pointers to ints lined up in memory)
1 comments

Yes, but this is different:

  int (* foo) [3]
This is a pointer to an array of 3 ints.

And you could pass this to an appropriate function as an argument, to pass the whole array, not just a decayed pointer.

And more generally, I'd group things as unambiguously as possible even in your example:

    int * (foo [3])
to make the intent clearer