/* teststruct2.cpp CIS 150 David Klick 7/3/08 This program demonstrates how to manipulate an array of structures. */ #include #include #include using std::cin; 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; }; const int ARRAY_SIZE = 5; void display(Employee e); void cont(); int main() { int i; // declare array of Employees Employee emp[ARRAY_SIZE]; // get Employee info from user for (i=0; i> emp[i].id; cin.ignore(); // get rid of newline after id cout << "First name: "; cin.getline(emp[i].fname, 15, '\n'); cout << " Last name: "; cin.getline(emp[i].lname, 15, '\n'); cout << " Rate: "; cin >> emp[i].rate; cout << '\n'; } // display employee info for (i=0; isungetc() != -1 && cin.get() != '\n') cin.ignore(80,'\n'); cout << "Press enter to continue..."; cin.get(); } /* Sample input/output: Employee #1 ID#: 27 First name: Sammi Last name: Hargrove Rate: 12.35 Employee #2 ID#: 62 First name: Red Last name: Forman Rate: 13.20 Employee #3 ID#: 13 First name: Eric Last name: Forman Rate: 16.50 Employee #4 ID#: 5 First name: Marcia Last name: Brady Rate: 8.95 Employee #5 ID#: 38 First name: Walter Last name: Savitch Rate: 10.50 27: Sammi Hargrove (12.35) 62: Red Forman (13.20) 13: Eric Forman (16.50) 5: Marcia Brady (8.95) 38: Walter Savitch (10.50) */