fstream - Binary file not working in c++ -


I am trying to create a binary file to store student class items. But the writing () function does not seem to work. When I call the function to write the data in the file, it accepts the data. But, when I query to display the content of the file, the data is not shown. Can anyone tell me what I am doing wrong here. Below is my code:

  #include & lt; Iostream & gt; # Include & lt; Fstream & gt; using namespace std; Class students {int marks; Public: get zero () {cin> & Gt; Icon; } Zero show () {cout & lt; & Lt; Icon & lt; & Lt; Endl; }}; Zero rit () {offstream F1; F1.open ("record.dat", ios :: application | ios :: binary); Student ob Ob.get (); F1.write ((four *) & amp; ob, sizeof (ob)); F1.close (); } Zero () {ifstream f2; F2.open ("record.dat", ios :: in | ios :: binary); Student ob While (F 2. Reid (four *) and ob, psychof (ob)) {ob.show (); } Cout & lt; & Lt; "EOF \ n"; F2.close (); } Int main () {int ch; Do {cout & lt; & Lt; "1- Enter data" & lt; & Lt; Endl; Cout & lt; & Lt; "2-Show Data" & lt; & Lt; Endl; The court's & lt; & Lt; "3-Quit" & lt; & Lt; Endl; CIN & gt; & Gt; Ch; The court's & lt; & Lt; "\ N \ n"; If (f == 1) write (); And if (f == 2) ri (); And break; } While (1); Return 0; }  


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -