Why are structures copied via memcpy in embedded system code?

Viewed 5269

In embedded software domain for copying structure of same type people don't use direct assignment and do that by memcpy() function or each element copying.

lets have for example

struct tag
{

int a;

int b;
};

struct tag exmple1 = {10,20};

struct tag exmple2;

for copying exmple1 into exmple2.. instead of writing direct

exmple2=exmple1;

people use

memcpy(exmple2,exmple1,sizeof(struct tag));

or

exmple2.a=exmple1.a; 
exmple2.b=exmple1.b;

why ????

9 Answers
Related