title: cast void* to a struct with an array member
body: <p>I'm trying to directly cast a stream of data into a structure that actually has a variable number of other structures as members. Here's an example:</p>
  
  <pre><code>    struct player
      {
          double lastTimePlayed;
          double timeJoined;
      };
  
      struct team
      {
          uint32_t numberOfPlayers;
          player everyone[];
      };
  </code></pre>
  
  <p>then I call:</p>
  
  <pre><code>    team *myTeam = (cache_team*)get_stream();
  </code></pre>
  
  <p>This should work like some kind of serialization, I know my stream is structured exactly as represented above, but I have the problem of the numberOfPlayers being a variable.</p>
  
  <p>My stream starts with 4 bytes representing the number of players of the team, then it contains each player (in this case, each player has only lastTimePlayed and timeJoined).</p>
  
  <p>The code posted seems to be working, I still get a warning from the compiler because of the default assignment and copy constructors, but my question is it it's possible to do this some other way, a better way.</p>
  
  <p>BTW, my stream is actually a direct mapping to a file, and my goal is to use the structure as if it was the file itself (that part is working properly). </p>