how to write vector of pointers to binary file
<p>i can write to file and read from it only if my program is running,if i close the program and open again and try to read from the file i get run time error
"vector iterator not dereferencable"</p>

<pre><code>    case 'd'://save to file
{
   file = fopen("final_proj.bin","w+b");
   t = arr.begin();
   fwrite( (*t), sizeof(figure3d), 1, file);
   system("cls");
   cout &lt;&lt; "saved to file successfully\n"&lt;&lt;endl ;
   fclose(file);
   flushall();
}



case 'e'://restore from file
{
file = fopen("final_proj.bin" , "r+b" );
t = arr.begin();
fread ((*t), sizeof(figure3d) , 1 , file);
temp.push_back(*t);
temp[0]-&gt;print();
/*arr.push_back(*t);*/
fclose(file);
}
</code></pre>
