title: Why doesn't fwrite() write a Binary File using "wb", in C, on Mac OS X?
body: <p>For the sake of learning C and understanding the difference between Binary Files and Text Files, I'm attempting to write a string to file as both file types like so:</p>
  
  <pre><code>char * string = "I am a string!";
  
  FILE * filePtrA = fopen("/output.txt", "wt");
  fwrite(string, strlen(string), 1, filePtrA);
  
  FILE * filePtrB = fopen("/output.bin", "wb");
  fwrite(string, strlen(string), 1, filePtrB);
  
  fclose(filePtrA);
  fclose(filePtrB);
  </code></pre>
  
  <p>However both <code>"wt"</code> and <code>"wb"</code> are writing as a Text File, where <code>"wb"</code> should be writing as a Binary File. Hex appears like so for both files:</p>
  
  <pre><code>49 20 61 6D 20 61 20 73 74 72 69 6E 67 21
  </code></pre>
  
  <p>Why is this happening, and how can I write something as a Binary File?</p>
  
  <p>I have read that the OS (Mac OS X 10.6 - GCC 4.2) might not differentiate between Binary and Text Files, though I'm still stumped why a hex editor wouldn't detect any difference.</p>