title: double free or corruption error when using fread in c++
body: <p>So basically I was writing a test program to see if I could write and read a vector of queues into a binary file using fwrite and fread respectively. Even though the reading and writing part is done correctly and the values are correct, I get a double free or corruption error. The test code is the following</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;vector&gt;
  #include &lt;queue&gt;
  
  int main(){
  
  vector&lt;queue&lt;unsigned&gt; &gt; hello(17);
  vector&lt;queue&lt;unsigned&gt; &gt; here(17);
  queue&lt;unsigned&gt; temp;
  for(int f=0;f&lt;4;f++){//initialise a random queue
      temp.push(f);
  }
  for(int i=0;i&lt;hello.size();i++){//assign random queue to every index of vector
      hello[i]= temp;
  }
  FILE *fo;
  fo = fopen("hello","wb");
  fwrite(&amp;hello[0],sizeof(queue&lt;unsigned&gt;),hello.size(),fo);
  fclose(fo);
  printf("Writing done!\n");
  
  FILE *fi;
  fi=fopen("hello","rb");
  fread(&amp;here[0],sizeof(queue&lt;unsigned&gt;),here.size(),fi);
  fclose(fi);
  printf("Reading done!\n");
  for(int i=0;i&lt;here.size();i++){
      printf("At key %d value at front is is %d",i,here[i].front());
      here[i].pop();
      printf(" value %d ",here[i].front());
      here[i].pop();
      printf(" value %d\n",here[i].front());
  }
  } 
  </code></pre>
  
  <p>The error seems to be when doing the fread operation.</p>