Copying array in C v/s copying structure in C
Arrays and structures in C store data in memory which is contiguous. Then
why is that C does not allow direct copying of arrays using "=" where as
it is allowed for structure. Example:
int a[3] = {1,2,3};
int b[3];
b = a; // why is this not allowed.
struct book b1, b2;
b1.page = 100;
b1.price = 10.0;
b2 = b1; // Why is this allowed
No comments:
Post a Comment