title: C - fwrite() not outputting to file
body: <p>Never used fwrite(), so I'm not sure exactly what I'm doing wrong. I'm just testing it now and all I want to do is try to write a single char out to a file until it reaches the end. The file I'm writing to is one I downloaded from my teacher's website. When I check the properties of it, the type is only listed as "file". It's supposed to just be an empty 2MB file for us to write our code to (file system lab if anyone's wondering). Here's my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  int main()
  {
      char c;
      FILE *fp;   
      char testing[2] = {'c'};  
  
      fp = fopen("Drive2MB", "rw"); 
  
      fseek(fp, 0, SEEK_SET);     //make sure pointers at beginning of file
      while((c=fgetc(fp))!=EOF)
      {
          fwrite(testing, 1, sizeof(testing), fp);
          fseek(fp, 1, SEEK_CUR);  //increment pointer 1 byte
      }
      fclose(fp);
  } 
  </code></pre>
  
  <p>When I run this, an error message pops up saying "Debug Assertion Failed!...Expression:("Invalid file open mode",0) and prints "The program '[3896] filesystem.exe: Native' has exited with code 3 (0x3)." </p>