This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Can memcpy() use in this way?

When needed read one unsigned long type variable from uart_buffer, the code following is false,how correct it?

like:
...
#include<string.h>
uchar x[2408]={0x12,0x34,0x56,0x78,...};
unsigned long lTemp=0;
unsigned int iDay = 2;
...
memcpy(&lTemp,&x[0],4);
//result: lTemp =0x12345678 NOT 0X78563412;
lTemp =0x12345678/1000 - iDay * 3600 * 24;
//result: lTemp = 0x3b48b NOT 0XB48B
...