/* teststruct1.cpp CIS 150 David Klick 6/30/05 The basics of using structures. */ #include #include #include using std::cout; using std::setw; using std::setprecision; using std::showpoint; using std::fixed; struct Employee { int id; char fname[15]; char lname[15]; double rate; }; void display(Employee e); int main(void) { // declare and initialize first Employee Employee e1 = {36, "Shirley", "Jackson", 27.35}; // declare next two Employees Employee e2, e3; // set fields of second Employee e2.id = 49; strcpy(e2.fname, "Horace"); strcpy(e2.lname, "Greeley"); e2.rate = 17.25; // copy employee data from one location to another e3 = e1; // display employee information display(e1); display(e2); display(e3); return 0; } void display(Employee e) { cout << fixed << showpoint << setprecision(2) << setw(3) << e.id << ": " << e.fname << ' ' << e.lname << " (" << e.rate << ")\n"; } /* Sample output: */