title: Method that returns uint16_t array properly in C++
body: <p>I have my C# code that returns uint array but I want to do it in C++. I looked other posts; they use uint pointer array where my array is not. Does anyone know how to return uint16_t array properly?</p>
  
  <blockquote>
    <p>This is C# code works fine</p>
  </blockquote>
  
  <pre><code>  public static UInt16[] GetIntArrayFromByteArray(byte[] byteArray)
          {
              if ((byteArray.Length % 2) == 1)
                  Array.Resize(ref byteArray, byteArray.Length + 1);
  
  
              UInt16[] intArray = new UInt16[byteArray.Length / 2];
  
  
              for (int i = 0; i &lt; byteArray.Length; i += 2)
                  intArray[i / 2] = (UInt16)((byteArray[i] &lt;&lt; 8) | byteArray[i + 1]);
  
  
              return intArray;
          }
  </code></pre>
  
  <blockquote>
    <p>This is C++ code that creates syntax error</p>
  </blockquote>
  
  <pre><code>uint16_t[] GetIntArrayFromByteArray(byte[] byteArray)
  {
      //if ((byteArray.Length % 2) == 1)
          //Array.Resize(ref byteArray, byteArray.Length + 1);
  
  
      uint16_t[] intArray = new uint16_t[10];
  
  
      for (int i = 0; i &lt; 10; i += 2)
          intArray[i / 2] = (uint16_t)((byteArray[i] &lt;&lt; 8) | byteArray[i + 1]);
  
  
      return intArray;
  }
  </code></pre>