I a writing a routine to append bytes to a byte_array like so
unsigned long speed = 0xfeb;
char byteArray[8];
bzero(byteArray,8); //fills every of the 8 bytes with zero
memcpy(byteArray,&speed ,4); //copies 4 bytes from speed to byteArray
After the operation i am expecting byteArray to have the value 0xfeb
but it turns out that byteArray has the value 0xebf
What is happening ? is it normal for memcpy to force the result to little-endianness ? What should i do to get the result without the change of endianness ?