title: sizeof(int) is 4 bytes but only two are written
body: <p>Consider the following simple program:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main () {
      FILE *fp;
  
      printf("sizeof(int)=%d\n", sizeof(int));
  
      fp = fopen("test.bin", "wb");
      fprintf(fp, "%d", 14);
      fclose(fp);
      return 0;
  }
  </code></pre>
  
  <p>It gives the following output to <code>stdout</code>:</p>
  
  <pre><code>sizeof(int)=4
  </code></pre>
  
  <p>test.bin has the following contents when viewed in any text editor:</p>
  
  <pre><code>14
  </code></pre>
  
  <p>When viewed with <code>vi</code> using the hex dump option (<code>xxd</code>):</p>
  
  <pre><code>0000000: 3134 0a                                   14.
  </code></pre>
  
  <p>When viewed with <code>hexdump -c</code>:</p>
  
  <pre><code>0000000   1   4  \n
  0000003
  </code></pre>
  
  <p>Obviously an integer on my machine is four bytes, but both <code>hexdump</code> and <code>vi</code> are telling me that only two bytes were required to represent 14, and another byte was used to represent the newline character. This is confirmed by the fact that test.bin is only three bytes in size. But, an integer is four bytes, so why are only two bytes representing it?</p>
  
  <p>What obvious fact have I completely forgotten and cant seem to remember?</p>