Assign one struct to another in C

cstruct

Can you assign one instance of a struct to another, like so:

struct Test t1;
struct Test t2;
t2 = t1;

I have seen it work for simple structures, bu does it work for complex structures?
How does the compiler know how to copy data items depending on their type, i.e. differentiating between an int and string?

Best Answer

Yes if the structure is of the same type. Think it as a memory copy.