Packing multiple variable into one string
<p>A stream of chars are sent out to a communication device. For readability purposes, i wrote inidividual configurations as variables: </p>

<pre><code>unsigned char a1;
unsigned char a2;
unsigned char a3;
unsigned char a4;
unsigned char a5;
std::string a6;
unsigned char a7;
unsigned char a8;
</code></pre>

<p>What is the best way to pack it into a variable tightly so that it's aligned perfectly?
Till now I've think of put everything into a <code>struct</code>.</p>

<p><strong>edit</strong>: <code>struct</code> doesn't look like a viable option since <code>struct</code> doesn't hold <code>string</code>, and string is varying in size, although is a one time declared thing. Compiled in GCC</p>

<p><strong>edit2</strong>: Gonna go with packed <code>struct</code> method, but will convert the <code>string</code> to a <code>c_str</code> first. Until a better answer, this is the way to  be.</p>
