W
WaterWalk
Hi, I'm haunted by 2 questions about struct copy. Though I searched the
net, but still in confusion.
1. Does struct assignment copies every member including array members?
For example,
struct A
{
int n;
int m[2];
} ;
struct A a = { 1, {2,3}};
struct A b = { 7, {8,9}};
After b = a; will b.m[0] and b.m[1] have the same value as in a? I
tested this using mingw, and the answer is yes. But i want to know if
this behavior is guaranteed by standard.
2. Does struct assignment equal to memcpy them?
If so, then after struct assignment, to apply memcmp on them will
return 0(equal); otherwise memcmp will return non-zero.
Any guidance?
net, but still in confusion.
1. Does struct assignment copies every member including array members?
For example,
struct A
{
int n;
int m[2];
} ;
struct A a = { 1, {2,3}};
struct A b = { 7, {8,9}};
After b = a; will b.m[0] and b.m[1] have the same value as in a? I
tested this using mingw, and the answer is yes. But i want to know if
this behavior is guaranteed by standard.
2. Does struct assignment equal to memcpy them?
If so, then after struct assignment, to apply memcmp on them will
return 0(equal); otherwise memcmp will return non-zero.
Any guidance?