Guest User

Untitled

a guest
Nov 18th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. int main() {
  2. Employee* employee = new Employee();
  3. cout << "Creating File..." << endl;
  4. fstream file("deneme1.txt",ios::out|ios::binary|ios::ate);
  5. for(int i=0;i<10;i++){
  6. if(i<4){
  7. string name;
  8. float salary;
  9. int yearHired;
  10. cout<<"Enter Name: ";
  11. cin>>name;
  12. cout<<"Enter Salary: ";
  13. cin>>salary;
  14. cout<<"Enter Year Hired: ";
  15. cin>>yearHired;
  16. employee->set_id(i);
  17. employee->set_name(name);
  18. employee->set_salary(salary);
  19. employee->set_yearHired(yearHired);
  20. file.write((char*)&employee,sizeof(employee));
  21. file.close();
  22. }
  23.  
  24. }
  25. file.open("deneme1.txt",ios::in|ios::out|ios::binary);
  26.  
  27. file.seekg(0);
  28.  
  29.  
  30. while((file.read((char*)&employee,sizeof(employee)))) {
  31. cout << employee->get_id();
  32. }
  33.  
  34.  
  35.  
  36. }
Add Comment
Please, Sign In to add comment