title: Dumping struct in C
body: <p>Is it a good idea to simply dump a struct to a binary file using fwrite?
  e.g</p>
  
  <pre><code>  struct Foo {
       char name[100]; 
       double f;
       int bar; 
    } data;
  
     fwrite(&amp;data,sizeof(data),1,fout);
  </code></pre>
  
  <p>How portable is it?
  I think it's really a bad idea to just throw whatever the compiler gives(padding,integer size,etc...). even if platform portability is not important.</p>
  
  <p>I've a friend arguing that doing so is very common.... in practice.
  Is it true???</p>
  
  <p>Edit: What're the recommended way to write portable binary file? Using some sort of library?
  I'm interested how this is achieved too.(By specifying byte order,sizes,..?)</p>