B
bb
Q: I need to copy and compare C Structs.
Is this the safe and quick way to do it?:
void func(void)
{
typedef _MY_STRUCT
{
int a;
char b;
char c;
} my_struct
my_stuct new;
my_struct old;
if (memcmp(old,new,sizeof(new))
{
memcpy(old, new, sizeof(new));
}
}
Is this the safe and quick way to do it?:
void func(void)
{
typedef _MY_STRUCT
{
int a;
char b;
char c;
} my_struct
my_stuct new;
my_struct old;
if (memcmp(old,new,sizeof(new))
{
memcpy(old, new, sizeof(new));
}
}