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 ...
Can memcpy() use in this way? C51 implements a big-endian model, so memcpy() can be used that way only when the data in uart_buffer is also big-endian.