title: Why is fwrite & fread printing garbage?
body: <p>When The following code is run, why is there extra garbage printed alongside the HALLO string?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main(void)
  {
      FILE *binfile;
  
      binfile = fopen("binary.bin", "wb+");
  
      char arr[5] = "HALLO";
      int integer = 1;
      double doub = 1.2345;
  
      fwrite(arr, sizeof(arr), 1, binfile);
      fwrite(&amp;integer, sizeof(int), 1, binfile);
      fwrite(&amp;doub, sizeof(double), 1, binfile);
  
      fclose(binfile);
  
      binfile = fopen("binary.bin", "r");
  
      char arr2[5];
      int integer2;
      double doub2;
  
      fread(arr2, sizeof(arr2), 1, binfile);
      fread(&amp;integer2, sizeof(int), 1, binfile);
      fread(&amp;doub2, sizeof(double), 1, binfile);
  
      printf("%s\n", arr2);
      printf("%d\n", integer2);
      printf("%lf\n", doub2);
  
      fclose(binfile);
      return EXIT_SUCCESS;
  }
  </code></pre>