/* Filename: recfind.cpp Author: Br. David Carlson Date: January 24, 1998 Last Revised: November 21, 2001 This program reads from the keyboard the data for a series of employees. (This data consists of each employee's first and last name, ID number, and wage rate.) The user is then allowed to repeatedly look up employee records by entering the user's last name and first name, with CTRL z entered to end lookups. (Substitute CTRL d in Linux, of course.) Tested with: Microsoft Visual C++ 6.0 Microsoft Visual C++ .NET g++ under Linux */ #include "emparray.h" /* Given: EmpArray Array of employee records, already in order. EmpCount Number of employee records in EmpArray. Task: To allow the user to do repeated lookups for the data on an employee by entering the person's name. Return: Nothing. */ void Lookups(EmpArrayType EmpArray, int EmpCount) { EmployeeType Employee; int Result; cout << "Prototype only!" << endl << endl; cout << "Enter last name of employee to find: "; cin >> Employee.LastName; cout << "Enter first name of this employee (or CTRL z to quit): "; cin >> Employee.FirstName; while (! cin.fail()) { // In this prototype, we assume that the BinarySearch has not // yet been written: // Result = BinarySearch(EmpArray, 0, EmpCount - 1, Employee); // Thus, we just provide fake data, by using the first array item: Result = 0; // Remove this line later! if (Result == -1) cout << "Could not find this employee" << endl; else PrintEmployee(EmpArray[Result]); cout << "Enter last name of employee to find: "; cin >> Employee.LastName; // Change to CTRL d for Linux: cout << "Enter first name of this employee (or CTRL z to quit): "; cin >> Employee.FirstName; } } int main(void) { EmpArrayType EmpArray; int Flag, EmpCount; Flag = LoadArray(EmpArray, EmpCount); if (Flag == TooMuchDataFlag) cout << endl << endl << "The data would not fit in the array" << endl; else Lookups(EmpArray, EmpCount); return 0; }