I understand from other posts that array assignment is not possible within C. However, array embedded within a structure seems to be properly transferred to another structure when structure assignment is performed.
For example:
struct test {
int a[3];
}
int main {
struct test test;
struct test test2;
test.a[0] = 123;
test.a[1] = 456;
test.a[2] = 789;
test2 = test;
printf("%d %d %d\n",test2.a[0],test2.a[1],test2.a[2]);
}
In the code above, the printed output would show 123, 456 and 789 (i.e. the values are correctly transferred from one structure to another).
Is it guaranteed that an array within a structure is properly "copied" to another structure when we perform such structure assignment?
Can somebody explain how such structure assignment happens (i.e. how/which memory is transferred)?
I understand that allocated memory within a structure is not copied (rather only the pointer is copied). Is it guaranteed that all other data (with non-allocated memory) will be copied correctly when structure assignment is carried out?