title: How can I write both an array of int and array of char to a file
body: <p>Im trying to write and read an array of ints in a binary file. The two functions look like this, more or less.</p>
  
  <h3>savefunction</h3>
  
  <pre><code>int numbers[6]={0, 2, 3, 3, 0, 1};
  FILE *file;
  if(file=fopen(filename, "wb")==NULL)
  {
      printf("Something went wrong reading %s\n", filename);
      return 0;
  }
  else
  {
      int i;
      for(i=0; i&lt;6; i++)
          fprintf(file, "%d", numbers[i]);
  }
  fclose(file);
  </code></pre>
  
  <h3>loadfunction</h3>
  
  <pre><code>FILE *saved_data;
  int errors=0;
  if((saved_data=fopen(filename, "rb"))==NULL)
      errors++;
  else
  {
      fread(first, sizeof(int), 1, saved_data);
      fread(second, sizeof(int), 1, saved_data);
      fread(third, sizeof(int), 1, saved_data);
      fread(fourth, sizeof(int), 1, saved_data);
      fread(fifth, sizeof(int), 1, saved_data);
      fread(sixt, sizeof(int), 1, saved_data);
  }
  fclose(saved_data);
  </code></pre>
  
  <p>Now when I debug the program the debugger tells me that the first element is the following</p>
  
  <pre><code>(gdb) print first
  $1 = (int *) 0x7fff5fbff968
  (gdb) print *first
  $2 = 858993200
  </code></pre>
  
  <p>I can't understand this. The file when opening with editor says <strong><em>023301</em></strong></p>