then you will find that the var2 not equal the var0, this is beacuse in windows/linux(mostly) use Little-Endian as the default, So you need to exchange var1 to 0x78,0x56,0x34,0x12, or rewrite a memcpy_ function.
1 2 3 4 5 6 7 8 9 10 11 12
void* memcpy_(void* _Dst, const void* _Src, size_t _Size) { uint8_t* d = (uint8_t*)_Dst; uint8_t* s = (uint8_t*)_Src; if (_Dst == _Src) { return _Dst; } int i = 0; while (_Size-- > 0) { d[i]=s[_Size]; i++; } }
this problem is easy, but a bit confusing, especially when dealing with a binary file.