Re:Everything I wish I knew when learning C
by dahfizz on Monday November 28, 2022 @11:46AM
(#33775869)
Another weird property about C arrays is that &arr == arr. The reference of an array is the pointer to the first element, which is what `arr` itself decays to. If arr was a pointer, &arr != arr.
[ Parent
| on HN ]
Re:Everything I wish I knew when learning C
by chasil on Monday November 28, 2022 @01:52PM
(#33777823)
I think it is clearer to say that arr == &arr[0] but your mileage may vary.
Re:Everything I wish I knew when learning C
by WalterBright on Monday November 28, 2022 @06:23PM
(#33781337)
Is today international speak like a pirate day? arr arr arr
Re:Everything I wish I knew when learning C
by naniwaduni on Tuesday November 29, 2022 @04:49PM
(#33793838)
&arr is a pointer to the array. It will happen to point to the same place as the first element, but in fact they have different types, and e.g. (&arr)[0] == arr != arr[0].