 <p>I figured I'd elaborate on my comment. I'd just have some bitwise fun.</p> <pre><code>char string[] = "123456" byte1 = ((unsigned char)string[0] &lt;&lt; 4) | (unsigned char)string[1]; byte2 = ((unsigned char)string[2] &lt;&lt; 4) | (unsigned char)string[3]; byte3 = ((unsigned char)string[4] &lt;&lt; 4) | (unsigned char)string[5]; </code></pre>