An lvalue
is defined as an expression to which a value can be assigned.
And it is illegal to assign and array with a array value. E.g.:
int x[2],y[2];
x = y;
Whereas structures can be treated as lvalue
s. Below structure assignment is valid.
typedef struct car {
char color[20];
int price;
} CAR;
CAR audi, bmw;
audi = bmw;
What is the difference?
There are historic reasons why arrays are not assignable on themselves, but are assignable inside struct
s. There is really no technical reason for this discrepancy.
Anecdottal heresay is that when C was designed, it was based on a certain language (don't remember which one!) which didn't have array assingment, so this feature was exluded from C as well - to preserve compatibility. However, this language didn't have struct
s, so array assingment inside struct
s was OKayed.