c++ - inverted byte order when casting from char[2] to short
<p>What I have is this</p>

<pre><code>struct Record
{
unsigned char cat;
unsigned char len[2]={0x00, 0x1b};  // can't put short here because that 
                                   // whould change the size of the struct
unsigned char dat[253];
};
Record record;
unsigned short recordlen = *((unsigned short*)record.len);
</code></pre>

<p>This result in <code>recordlen=0x1b00</code> instead of <code>0x001b</code></p>

<p>Same with <code>*reinterpret_cast&lt;unsigned short*&gt;(record.len)</code></p>

<p>Can you explain why ? How should I be doing this ?</p>
