title: Cast an unsigned short/int to char *
body: <p>I have a function like this </p>
  
  <pre><code>void UnitTestWorker::constructTestPayload(QByteArray &amp;payload)
  {
      QString List = "127.0.0.1";
      unsigned short Port = 12344;
      unsigned int RequestId = 1;
      memcpy(payload.data(),reinterpret_cast&lt;char*&gt;Port,sizeof(Port));
      memcpy(payload.data()+sizeof(Port),reinterpret_cast&lt;char*&gt;RequestId ,sizeof(RequestId ));
  }
  </code></pre>
  
  <p>But I am getting access violation error, it seems like I can't do something like <code>reinterpret_cast&lt;char*&gt;Port</code> or <code>reinterpret_cast&lt;char*&gt;RequestId</code>.</p>