title: C fwrite writes extra zeros
body: <p>when i read from the result.bin file it puts the value i want then fill with 3 zeros then next value and so on i cant figure out why tried diffrent compilers (minigw cygwin and msdn) same result on all.
  also tried reading it in matlab and using the functions in the libraries stdio,stdlib</p>
  
  <p>first sorry for the bad posting i was in a hurry here is a better hopfully more clear description:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  /*
   * 
   */
  int main() {
      int output[4];
      int k=0;
  
      output[0]=1;
      output[1]=11;
      output[2]=2;
      output[3]=22;
  
      FILE *result;
      result=fopen("C:/Users/Mattias/Desktop/result.bin","w+b");
      fwrite(output,sizeof(int),4,result);
                          printf("%d\n", output[0]);
                          printf("%d\n", output[1]);
                          printf("%d\n", output[2]);
                          printf("%d\n", output[3]);
  
      fclose(result);
  
  
      result=fopen("C:/Users/Mattias/Desktop/result.bin","r+b");
      printf("%s\n", "whats written to result");
  
          int buffer1[3];
          long int size = sizeof(buffer1);
  
      if (!result)
      {
              printf("Unable to open file!");
          return 1;
      }
      for ( k=0; k &lt;= 3; k++)
      {
              buffer1[k]=fgetc(result); 
              printf("%d\n", buffer1[k]);
      }
          fclose(result);
  
      return (EXIT_SUCCESS);
  }
  </code></pre>
  
  <p>and the output i get from reading the result.bin file is:</p>
  
  <p>1
  0
  0
  0
  11
  0
  0
  0
  2
  0
  0
  0
  22
  0
  0
  0
  and what i want to get when i read is just 1 11 2 22
  Thanks for the help
  ps. i used a 1 in fwrite becouse i know the data iam handeling is only 1 byte big </p>