c++ - unsigned char array to unsigned int back to unsigned char array via memcpy is reversed -


This is not cross-platform code ... everything is being done on the same platform (i.e., Andyenes is similar. / P>

I have this code:

  Unsigned four array [4] = {'T', 'E', 'S', 'T'}; 
unsigned integer = ((array [0] < 16) | (array [2] < unsigned four fans [4]; Memcpy (buff, and; out; shapes (unsigned Int));
std :: cout & lt; buffet & lt; ; & Lt; std :: endl;

I believe that the "test" (due to the lack of '/ 0' with the letter behind the trash) Expected, but instead of changing the order of "tset." The characters, I solve the problem (rather than 0, 1, 2, 3 instead of 3, 2, 1, 0), but I have problems Did not understand what Memkpi does not act like I expect?

Thanks.

The reason for this is In the memory of the cooked CPU, the array is stored in this form:

  + ---- + ---- + ---- + ---- + array | 74 | 65 | 73 | 74 | + ---- + ---- + ---- + ---- +  

This indicates rising with a byte address > Right . However, the integer is stored in less important bytes on the left side in memory:

  + ---- + ---- + ---- + - --- + out | 74 | 73 | 65 | 74 | + ---- + ---- + ---- + ---- +  

This integer is for representing 0x74657374 mempi () to copy it from your original array to buff bytes.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -