...
This compliant solution uses memcpy
to convert the short
s to an int
:
Code Block | ||||
---|---|---|---|---|
| ||||
#include <stdio.h> #include <string.h> void func(void) { short a[2]; a[0]=0x1111; a[1]=0x1111; int i = 0x22222222; memcpy(a, &i, sizeof a); printf("%x %x\n", a[0], a[1]); } |
...