I am having a problem with storing unsigned ints in a character array in C. The code i have is
static unsigned char dataArray[8];
// values before are 2400 and 2100
// array layout: 0 0 0 0 0 0 0 0
U32 sysTime1 = 2400;
U32 sysTime2 = 2100;
dataArray[0] = sysTime1;
dataArray[4] = sysTime2;
// values after are 96 and 52
// array layout: 96 0 0 0 52 0 0 0
How do i get the correct values to be stored in the array? I thought that if you stored a four byte data type in a char array from index 0, it would take up room from index 0 to 3 and so on. Any help would be much appreciated. The U32 is an unsigned 32 bit (4 byte) integer.