title: crash after memcpy: access violation reading location
body: <pre><code>if (m_Connections[t].socket != INVALID_SOCKET)
  {
      m_TCPResult = recv(m_Connections[t].socket, m_TCPRecvbuf, m_TCPRecvbuflen, 0);
  
      if (m_TCPResult &gt; 0)
      {
          printf("[TCPReceive] Bytes (m_TCPResult) received from %d: %d\n", m_Connections[t].socket, m_TCPResult);
  
          // Deserialize the data
          Packets::MainPacket receivedData;
          memcpy(&amp;receivedData, m_TCPRecvbuf, sizeof(receivedData));
  
          // Check the type and do something with the data
          CheckType(m_Connections[t].socket, receivedData);
      }
      else  
      {
          if (WSAGetLastError() != WSAEWOULDBLOCK)
              printf("TCPReceive error: %d\n", WSAGetLastError());
      }
  }
  </code></pre>
  
  <p>So I have this piece of code. I need to do a memcpy() to convert the incoming data from winsock to a struct that can be read by the application. However, after the CheckType() method is done the application crashes giving me an Access Violation Reading Location error. I removed the memcpy() method once to check and then it worked fine (no crashes).</p>
  
  <p>I have no idea what the problem might be. I've been searching on Google but haven't found anything useful that seems to be a solution to my problem</p>
  
  <p>EDIT:</p>
  
  <p>Some more info:</p>
  
  <pre><code>// in the header
  char m_TCPRecvbuf[DEFAULT_BUFLEN];
  
  // receivedData struct
  struct MainPacket
  {
      char type;
      int id;
  
      LoginData loginData;
      vector&lt;PlayerData&gt; playerData;
  };
  </code></pre>