Note that there are some explanatory texts on larger screens.

plurals
  1. POUnhandled exception at 0x5DF9CCC8
    text
    copied!<p>when i run this code everything goes fine when writing , but when i press 2 to read it goes well and read everything just fine but when it it finishes reading the file (show function) it pops up a problem says " Unhandled exception at 0x5DF9CCC8 " with break , continue options . from my searching i think the problem comes from a pointer points to Null , but i don't know how to resolve it . here is the code </p> <pre><code>class person{ public : string name; int id ; int age ; void person :: show(); void person :: add_menue(); void person :: insert_data(); void person :: show_data(); }; person personobject; void person :: add_menue() { cout &lt;&lt; "Please Enter Name ID Age :" &lt;&lt; endl; cin &gt;&gt; name &gt;&gt; id &gt;&gt; age ; } ofstream file; void person::show() { cout&lt;&lt;"Age =&gt; "&lt;&lt;age&lt;&lt;endl; cout&lt;&lt;"Name =&gt; "&lt;&lt;name&lt;&lt;endl; cout&lt;&lt;"ID =&gt; "&lt;&lt;id&lt;&lt;endl; } void person :: insert_data() { ofstream file; file.open("binary.dat",ios::app| ios::binary); personobject.add_menue(); file.write((char*)&amp;personobject, sizeof(personobject)); file.close(); } void person :: show_data() { ifstream file; file.open("binary.dat",ios::in| ios::binary); if(!file) { cout&lt;&lt;"File not Found"; } else { file.read((char*)&amp;personobject, sizeof(personobject)); while(!file.eof()) { personobject.show(); cout&lt;&lt;"Press Any Key....For Next Record"&lt;&lt;endl; getchar(); file.read((char*)&amp;personobject, sizeof(personobject)); } } file.close(); } void main () { int choice; cout &lt;&lt; "1 - to write \n2 - to read" &lt;&lt; endl; cin &gt;&gt; choice; if (choice==1) { person f; f.insert_data(); } if (choice==2) { person a; a.show_data(); system ("pause"); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload