title: fwrite() function in C does not write the expected answer
body: <p><strong>Hello, everyone!</strong></p>
  
  <p>I found a programming exercise into an old book:</p>
  
  <p>"The content of the <strong>a.txt</strong> file is: <strong>11 2 13 4 15 6 17 8 19</strong> .We have the following program in C that writes something in the <strong>b.txt</strong> file:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main()
  {
      FILE *f, *g;
      short int v[10];
  
      f = fopen("a.txt", "r");
      g = fopen("b.txt", "w");
  
      fread(v, 8, 1, f);
      fwrite(v, 6, 1, g);
  
      fclose(f); fclose(g);
  
      return 0;
  }
  </code></pre>
  
  <p>I expected my program to write these numbers: <strong>11 2 13</strong>
   .But instead, it wrote: <strong>11 2 1</strong></p>
  
  <p>I tried to see what happens with the <strong>v</strong> array with the Debugger, but the 
  values showed there does not correspond to my calculations. </p>
  
  <p>Before the fread() is called, v is uninitialized like this: <strong>6448 64 -108 96 6542 64 6448 64 68 0</strong></p>
  
  <p>After the fread()
  function completes, the v in Debug mode is: <strong>12593 12832 12576 8243 6542 64 6448 64 68 0</strong></p>
  
  <p>I don't study C anymore, but I'm curious how fread() reads the numbers from a.txt and how fwrite() writes them in b.txt. I know the functions prototipes and how they generally work, because I wrote some little programs using them:</p>
  
  <pre><code>int fread(void *p, int dim, int n, FILE *f);
  //reads n elements from f, each one having dim bytes and stores them in p
  
  int fwrite(void *p, int dim, int n, FILE *f);
  //writes n elements in f from p, each one having dim bytes
  </code></pre>
  
  <p>But in this particular case, I'm confused. I even tried to change the type of my array from <strong>short int</strong> to <strong>int</strong>, but the result is the same. I checked the book and the <strong>int</strong> type has 4 bytes and "short int" has 2 bytes if that helps.</p>