I want to combine four single bytes of data to one datum of four bytes.
#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { unsigned long int sdata = 0x12*(16^6) + 0x34*(16^4) + 0x56*(16^2) + 0x78; printf("%x %d", sdata, sizeof(sdata)); return 0; } The screen prints:
c20 4 I want to get:
sdata = 0x12345678 The type unsigned long int is a 4 byte data type, so why can't it save the data? Why is the output wrong?