Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main() {
- Employee* employee = new Employee();
- cout << "Creating File..." << endl;
- fstream file("deneme1.txt",ios::out|ios::binary|ios::ate);
- for(int i=0;i<10;i++){
- if(i<4){
- string name;
- float salary;
- int yearHired;
- cout<<"Enter Name: ";
- cin>>name;
- cout<<"Enter Salary: ";
- cin>>salary;
- cout<<"Enter Year Hired: ";
- cin>>yearHired;
- employee->set_id(i);
- employee->set_name(name);
- employee->set_salary(salary);
- employee->set_yearHired(yearHired);
- file.write((char*)&employee,sizeof(employee));
- file.close();
- }
- }
- file.open("deneme1.txt",ios::in|ios::out|ios::binary);
- file.seekg(0);
- while((file.read((char*)&employee,sizeof(employee)))) {
- cout << employee->get_id();
- }
- }
Add Comment
Please, Sign In to add comment