I was experimenting with pointer manipulation and decided to try converting an array of numbers into an integer by directly copying from memory using memcpy.
char aux[4] = {1,2,3,4};
int aux2 = 0;
memcpy((char*) &aux2, &aux[0], 4);
printf("%X", aux2);
I expected the result to be 0x1020304 since I'm copying the exact bytes from one to another, but printf gives me the result 0x4030201, which is almost my desired output, only backwards. Why does this happen and is there a way to get the result in the "correct" order?