Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream.h>
- #include <fstream.h>
- #include <iomanip.h>
- #include "Person.h"
- void main()
- {
- Person p;
- Person q;
- fstream file; //stream for input AND output
- file.open("People.dat",ios::in|ios::out);
- cout<<"Enetr details of 1 Person: \n";
- p.readData();
- file.write((char*)&p,sizeof(p));
- file.seekg(0); //go to the start
- cout<<"\nReading from the file: \n";
- //here you can user while(file) if you dont know how big the file is
- //Invoked on a differnt object just to prove it works :D
- file.read((char*)&q,sizeof(q));
- q.writeData();
- file.close();
- }
Add Comment
Please, Sign In to add comment