int a[10];
int b[10];
a = b; // illegal
typedef struct {
int real;
int imag;
} complex;
complex c,d;
c = d; //legal
[I realize that
Because C says you can't, it says "A modifiable lvalue is an lvalue that does not have array type, does not have an incomplete type", so an array can't be assigned to.
Moreover,
When you use the name of an array in a value context likea = b;
, both the names a
and b
mean
&a[0]
and &b[0]
. Often referred to as an array "decaying" to a pointer.
However, arrays are not pointers, so trying to assign an array by using pointers wouldn't make sense.