/* testdgkio.cpp CIS 150 7/1/05 David G. Klick Usage demonstration for functions in dgkio.h file. */ #include "dgkio.h" #include using std::cout; using dgk::getInt; using dgk::getDouble; using dgk::processMenu; int main(void) { char* menu = "Main menu\n\n" "1. (F)irst choice\n\n" "2. (S)econd choice\n\n" "3. E(x)it\n\n"; char allowed[] = "123FfSsXx"; char prompt[] = "Enter choice: "; int n; double x; char choice; // test: int getInt(char*, int, int) n = getInt("Enter an integer (10-20): ", 10, 20); cout << "You entered " << n << '\n'; // test: double getDouble(char*, double, double) x = getDouble("Enter a float (-10.2 - 20.5): ", -10.2, 20.5); cout << "You entered " << x << '\n'; // test: char processMenu(char*, char*, char*, bool) do { choice = processMenu(menu, prompt, allowed, true); cout << "You entered: " << choice << '\n'; } while (choice != '3' && choice != 'X'); return 0; }