Converting char[] to uint16 (unsigned short) gives wrong numbers
<p>I have a problem converting a char array to a unsigned short (UInt16). My converting techniques seems to be wrong...
Here is the code: </p>

<pre><code>#include "stdafx.h"
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;


int _tmain(int argc, _TCHAR* argv[])
{
    // Symbols 0x1210 :
    char test[2];
    test[0] = 0x12;
    test[1] = 0x10;

    unsigned short n;
    memcpy(&amp;n, test, sizeof(unsigned short));

    int i=0, arrToInt=0;
    for(i=1;i&gt;=0;i--)
        arrToInt =(arrToInt&lt;&lt;8) | test[i];

    /*
    Now are:

    n = 4114
    arrToInt = 4114

    But! -&gt; 0x1210 == 4624
    */

    return 0;
}
</code></pre>

<p>Is there a way (without) reversing the char array?</p>

<p>Thanks for your help!</p>
