edelossantos
asked on
Employee.cpp
>> Need checked, please advise. Del
#include <iostream>
#include <fstream>
using namespace std;
int main(void)
{
struct employee {
char name[64];
int age;
int sex;
int phone;
float salary;
} worker = {"peter", 2, 25000};
ofstream emp_file("employee.DAT", ios::app);
emp_file.write((char *) &worker, sizeof(employee));
ifstream mp_file("employee.DAT");
while (!mp_file.eof())
{
mp_file.read((char *) &worker, sizeof(employee));
cout << "Name: " << worker.name << endl;
cout << "Sex: " << worker.sex << endl;
cout << "Age: " << worker.age << endl;
cout << "Phone: " << worker.phone << endl;
cout << "Salary: " << worker.salary << endl;
}
return 0;
}
**********************
employee.DAT
**********************
Name: Enrique (Del) De Los Santos
Sex: Male
Age: 41
Phone: USA-COMP
************************
#include <iostream>
#include <fstream>
using namespace std;
int main(void)
{
struct employee {
char name[64];
int age;
int sex;
int phone;
float salary;
} worker = {"peter", 2, 25000};
ofstream emp_file("employee.DAT", ios::app);
emp_file.write((char *) &worker, sizeof(employee));
ifstream mp_file("employee.DAT");
while (!mp_file.eof())
{
mp_file.read((char *) &worker, sizeof(employee));
cout << "Name: " << worker.name << endl;
cout << "Sex: " << worker.sex << endl;
cout << "Age: " << worker.age << endl;
cout << "Phone: " << worker.phone << endl;
cout << "Salary: " << worker.salary << endl;
}
return 0;
}
**********************
employee.DAT
**********************
Name: Enrique (Del) De Los Santos
Sex: Male
Age: 41
Phone: USA-COMP
************************
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER