Up until recently, I have only seen copying of structure fields done with memcpy(). In classes and online instructions, copying the contents of one struct into
Some people prefer memcpy because that's what they learned and they never figured out that they could just do an assignment (in ancient times the assignment wasn't allowed, but that's a long long time ago). There are no alignment problems to worry about since memory allocated by malloc () is always aligned correctly. And since a compiler could trivially translate this assignment to a memcpy call, it would never be slower or more code than memcpy. Of course there are embedded systems with badly outdated compilers.