title: Integers not writing to file in C
body: <p>The following code runs fine, except my output file does not contain the integer 10, but instead the characters ^@^@^@ when I open it up in VIM. If I open it in textedit (on the mac) the file appears to be empty.</p>
  
  <p>Does anybody know where I am going wrong here?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  #define MAX_LINE 256
  #define MAX_NAME 30
  
  int main() {
     FILE *fp;
     char fname[MAX_NAME] = "test1.dat"; 
     int x =10;
     int num= 0;
  
     if( (fp =fopen(fname, "w")) == NULL) {
        printf("\n fopen failed - could not open file : %s\n", fname);
        exit(EXIT_SUCCESS);
     }
  
     num= fwrite(&amp;x, sizeof(int), 1, fp);
     printf("\n Total number of bytes written to the file = %d\n", num);
  
     fclose(fp);
  
     return(EXIT_SUCCESS);
  }
  </code></pre>