January 10th, 2013, 10:24 PM
Join Date: Nov 2012
Time spent in forums: 5 h 19 m 31 sec
Reputation Power: 0
How to copy the data from a struct/union variable
I want to copy the data of a to b, or just the union part of a to b. There two ways:
(1) b = a; b.e = a.e;
(2) memcpy(&b,&a, sizeof(a)); memcpy(&b.e,&a.e, sizeof(a.e));
I am confused and not sure which method is correct.
I hope someone can explain.