title: FILE * creation error: Unhandled exception (ucrtbased.dll) Access violation reading location
body: <p>I'm working with a simple fopen, fwrite, fflush, fclose body of code. For some reason, however, every time I try to create a <code>FILE *</code> object, it crashes. My code is below.</p>
  
  <pre><code>//fopen
  FILE * f_data = fopen("out.txt", 'wb'); // BREAKS HERE
  if (f_data == NULL) { printf("fopen failed!"); }
  
  //fwrite
  int fwritten = fwrite(data, 1, content_length, f_data);
  if (fwritten == 0) { printf("fwrite failed!"); }
  
  //fflush
  int flush = fflush(f_data);
  if (flush != 0) { printf("fflush failed!"); }
  
  //fclose
  int close = fclose(f_data);
  if (close != 0) { printf("fclose failed!"); }
  </code></pre>
  
  <p>Whenever I run this code, I get the following error:</p>
  
  <blockquote>
    <p>Unhandled exception at 0x5F52C795 (ucrtbased.dll) in main.exe: 0xC0000005: Access violation reading location 0x00007762.</p>
  </blockquote>
  
  <p>I've been researching this problem for about an hour now, to no avail. I've learned that this is Windows telling me I've encountered a segmentation fault, possibly from trying to dereference a <code>NULL</code> pointer.</p>
  
  <p>If anybody has some insight on why my File * instantiation won't work, please share!</p>
  
  <p>EDIT: I'm not sure it's relevant to this question but the <code>data</code> buffer being written is a simple string: "Hello, world, and all who inhabit it!" and <code>content_length</code> is set to <code>sizeof(data)</code>.</p>