Hi everyone. I am a new member. I am relatively new to C and I would like to ask you how to copy two structures that contain pointers as members. For example, I have this code fragment
How can I make a copy of obj1 to obj2 ?Code:struct myStruct { int *x1; int x2; }; void main() struct myStruct obj1; struct myStruct obj2; obj1.x1 = malloc(5*sizeof(int)); *obj1.x1 =40; obj1.x2 =20;
Thanks