This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Converting unsigned char[] to long?

How can you access the individual bytes making up a variable of type long? What I need to do is move a 24-bit (3 bytes) unsigned char array into a long variable. An example:

unsigned char a[3];
unsigned long b;

a[0] = 0x02;
a[1] = 0xFF;
a[2] = 0xFF;

?????
?????


TIA!
James

Parents
  • "Casting the pointer seemed to do the trick just fine."

    but don't forget that it relies upon C51's internal data representation - so it would be a good idea to do something like Drew's idea to ensure that nobody forgets this and tries to re-use the code on a different target...

Reply
  • "Casting the pointer seemed to do the trick just fine."

    but don't forget that it relies upon C51's internal data representation - so it would be a good idea to do something like Drew's idea to ensure that nobody forgets this and tries to re-use the code on a different target...

Children
No data