how do i turn a 16 bit int into two 8 bit char variables?
Posted on 2004-11-13
the title pretty much says it all. the code i was using is as follows.
void breakdown(int number, char *high, char *low)
*low = (number);
*high = (number>>8);
*high corresponds to the upper 8 bits of the integer and *low corresponds to the lower 8 bits of the integer. also, if you have any suggestions on how to implement the reverse process, it would be appriciated. our current code for that is as follows.
char highdata, lowdata;
//assignment of highdata and lowdata
int build, result = 0;
build = (lowdata);
result = (highdata)<<8;
result = (highdata | build);
this does not seem to be working. any suggestions would be appriciated :)