Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 1
    The confusion is really caused by the fact that you CANNOT HAVE an array as a function parameter -- if you declare a function parameter as an array, the compiler silently turns it into a pointer for you, "helpfully" concealing any misunderstanding and leading to errors like these. Commented Sep 30, 2014 at 2:48
  • @ChrisDodd yes, but don't forget about multidimensional arrays which have different rules. Commented Sep 30, 2014 at 14:39
  • No such thing as multidimensional arrays in C -- only arrays of arrays, which turn into pointers when used as arguments, just like any other array. Then there's also the confusion between arrays of arrays and arrays of pointers, which are completely different despite the fact they can be accessed with the same syntax. Commented Sep 30, 2014 at 16:03
  • @ChrisDodd whether or not to call them multidimensional arrays, I'm just pointing out that int f(int a[][5]) { printf("%zu\n", sizeof a[0]); } prints sizeof(int) * 5 not sizeof(int *) Commented Sep 30, 2014 at 16:08
  • 1
    @StevenK I think you mean int *const Commented Dec 11, 2014 at 19:59