I am more confused with structures. There are many ways to copy a structure.
struct complex
{
int real;
int imaginary;
};
Assume c1 is complex structure v
Changing the order of structure members has no effect in this case. Struct fields are explicitly stated, as you mentioned.
When things get more complex, it's easier to make mistakes. As you did:
memcpy(&c1.real, &c2->real, sizeof(struct complex));
It should have been:
memcpy(&c1.real, &c2->real, sizeof(c1.real));
Simpler is better:
c1.real = c2->real;
By using memcpy there is also another problem; you lose type safety. Sometimes you want that, but not usually when working with 2 entities with same data type.