title: Writing ByteArray to file in c
body: <p>I have a struct which holds some ByteArray data</p>
  
  <pre><code>typedef struct {
      uint32_t length;
      uint8_t* bytes;
  } FREByteArray;  
  </code></pre>
  
  <p>And here I am trying to save this to a file</p>
  
  <pre><code>FREByteArray byteArray;
  
  if((fileToWrite = fopen(filePath, "wb+")) != NULL){
      fwrite(&amp;byteArray.bytes, 1, byteArray.length, fileToWrite);
      fclose(fileToWrite);
  }
  </code></pre>
  
  <p>But this doesn't seem to be saving all of the data, the saved file size is 16KB, actual data is about 32KB. I think fwrite is not able to write the whole bytearray to the file. </p>
  
  <p>Is this the correct way to save the ByteArray? Is there a limit how much fwrite can handle in a single call?</p>