How can I concatenate upper and lower nibbles stored sequentially in an array?

Posted by Abhijit Kumar on Stack Overflow See other posts from Stack Overflow or by Abhijit Kumar
Published on 2009-01-09T10:14:42Z Indexed on 2010/03/15 8:49 UTC
Read the original article Hit count: 300

Filed under:
|
|

Hi friends,

I have an array which contains a list of nibbles:

{0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, ...}

I want to combine adjacent nibbles into single bytes by left-shifting the upper nibble and concatenating it with the lower one. The output should look as follows:

{0xab, 0xcd, 0xef, ...}

How can I accomplish this in C?

© Stack Overflow or respective owner

Related posts about c

    Related posts about bit-shift