title: writing binary file in C
body: <p>I realize this question has been asked a ton, and I've searched through (most) of the articles, but I just can't seem to write a file in binary. I can open the file and write in human-readable format, but what I want is non-human-readable data written to the file (like hex). I'm aware of the "xxd" command on Linux, but I'm wondering how I can mimic that using C. The relevant code I have so far is as follows (the opening of the file followed by the writing of the file:</p>
  
  <pre><code>extern FILE* file;
  static char file_buffer[16384];
  file = fopen("audit_log", "wb");
  
  if ( !file )
  {
      printf("failed to open file");
      exit(1);
  }
  
  
  if ( !fwrite( &amp;file_buffer, 1, sizeof(file_buffer), file ) )
      printf("fwrite failed\n");
  
  fclose(file)
  </code></pre>
  
  <p>I've done my research and my testing and used all different kinds of modes for fopen() using the "b" parameter, paired with fwrite(), but none of these methods have aided me in writing a binary file to C. Am I missing something trivial? I can't seem to figure out why I can't write a simple file in binary. Thanks! </p>