3 ms·
> Why is this [array assignment] failing? Because the array’s name is a lie! Using a variable as an expression normally yields its value, but in the case of a
by kazinator 10y ago
> Why is this [array assignment] failing? Because the array’s name is a lie! Using a variable as an expression normally yields its value, but in the case of arrays the array name yields a pointer (to the first element; which is at least reasonable)
Sorry, no; the assignment fails because an array isn't a modifiable lvalue. Array assignment simply isn't supported.
If array assignment were supported the array-to-pointer conversion ("decay") could be suppressed in that case to make it work. Just like it is suppressed when an array is the operand of sizeof of & (address-of).
Assignment of arrays is supported when they are struct/union members:
struct wrapper {
int a[5];
} x = { 0 }, y = x;
We can return this from a function, too.