 <p>You can do this using <code>void</code> pointer:</p> <pre><code>void *ptr = str; uint8_t version = *(uint8_t*)ptr; ptr = *(uint8_t*)ptr + 1; uint16_t type = *(uint16_t*)ptr; ptr = *(uint16_t*)ptr + 1; uint16_t program = *(uint16_t*)ptr; ptr = *(uint16_t*)ptr + 1; </code></pre> <p>Writing this variables to <code>char* string</code> you can perform in the same way (using void pointer).</p>