News for hackers. Stuff that matters.
Re:Are pointers and arrays equivalent in C? (2009) by Peaker on Saturday March 21, 2015 @04:12PM (#9244043)
No. An array has size (N * sizeof(element)). Arrays are immutable in their address in the same sense that any lvalue is immutable in its address.

  int x;
  int y[2];
The two declarations above are similar, one happens to be an (int). The other an (int[2]).

The difference is that when you take the rvalue of an int, say x, you get an rvalue int. When you take the rvalue of an int[2], you get a degraded (int *) rvalue that points to its first element.

Until you convert the array object to an rvalue, it is no more related to an (immutable) pointer than the above int. Both have an immutable address, like all lvalues do.

There are no comments on this comment yet.