There are a number of problems here: char quantities are aligned on byte boundaries, but integers aren't - they are aligned on word boundaries.
What that means is that the address of a char based value can be 0, 1, 2, 3, 4, 5, 6 ... but the address of an integer can only be 0, 4, 8, 16, ...
The reason for this has to do with how the processor works and how memory is actually addressed. Trying to "stuff" an integer value into a char based address can easily end up with other memory getting corrupted, or the wrong values going into the wrong locations.
If that wasn't the case, you could just go:
int *pi = (int *)a;
*pi = 0xff00;
But...even if that worked because the addresses were fine there would be another problem: Endianness. The PC processor is what is called "Little Endian", which means that it stores the least significant byte of a value in the lowest order address: so the value would go in the wrong way round, with 0x00 in a[0], and 0xFF in a[1]. (Even if it wasn't, since most processors are 32 or 64 bit these days with very few being 16 bit, it would still not get the right values in the right locations.
But...you can do it:
unsigned char a[2];
int i = 0xFF00;
a[0] = (unsigned char) (i >> 8);
a[1] = (unsigned char) (i & 0xFF);
It's just probably not a useful thing to do! :laugh: