title: Unfixed structure in C/C++
body: <p>I have A structure named TOWRITE.  I want to write the contents the structure into a file.  But one thing is size of a member of structure is unfixed.  It depends on data received from another source.  Is it possible to write structure by easy way.  please refer below code snippet.</p>
  
  <p>thanks</p>
  
  <pre><code>typedef struct TOWRITE
  {
     DWORD dwHeader;
     WORD datacount;
     LPBYTE lpData;
     WORD checksum;
  }
  
  TOWRITE towrite;
  ZeroMemory( &amp;towrite, sizeof( TOWRITE ));
  towrite.lpData = (LPBYTE) new BYTE[256];
  
  towrite.dwHeader = 0xF1F1E1E1;
  towrite.datacount = 256;
  towrite.cheksum = 3849;
  CopyMemory( towrite.lpData, szTemp, 256 );
  
  .....
  
  .....
  
  .....
  
  f.write( (LPBYTE)&amp;towrite, sizeof(TOWRITE) );
  ....
  ....
  ....
  ....
  </code></pre>