Hi,
zuerst mal den Wert in 2 x 2 Byte aufteilen
Code:
unsigned short HiWord = (unsigned short)(Data >> 16);
unsigned short LoWord = (unsigned short)(Data);
dann diese 2 Words wieder in je 2 Bytes aufteilen:
Code:
array[0] = (unsigned char)(LoWord);
array[1] = (unsigned char)(LoWord >> 8);
array[2] = (unsigned char)(HiWord);
array[3] = (unsigned char)(HiWord >> 8);
[edit]
Hab's gerade mal probiert, geht auch in einem Schritt:
Code:
array[0] = (unsigned char)(Data);
array[1] = (unsigned char)(Data >> 8);
array[2] = (unsigned char)(Data >> 16);
array[3] = (unsigned char)(Data >> 24);
[/edit]
Gruß,
askazo
Lesezeichen