Preference between memcpy and dereference
问题 When copying a known struct in memory, would you prefer using memcpy or dereference? why? Specifically, in the following code: #include <stdio.h> #include <string.h> typedef struct { int foo; int bar; } compound; void copy_using_memcpy(compound *pto, compound *pfrom) { memcpy(pto, pfrom, sizeof(compound)); } void copy_using_deref(compound *pto, compound *pfrom) { *pto = *pfrom; } int main(int argc, const char *argv[]) { compound a = { 1, 2 }; compound b = { 0 }; compound *pa = &a; compound