|
simple menu
Found a simpler way of building a menu & I also want to seperate it into its own function, I have done some of it, I wanted to build the menu first, but I keep getting an undeclared identifier error, then a redefinition error, please take a look at my code, here is the code:
// krisleblanc3.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream"
#include "iomanip"
#include "conio.h"
using namespace std;
int menu();
int _tmain(int argc, _TCHAR* argv[])
{
cout << " Main function enetered later. ";
getch();
return 0;
}
int menu()
{
char choice;
do
{
choice = toupper(display_menu());
switch (choice)
{
case 'A':
cout << "Please enter a positive whole number: " << endl;
break;
case 'B':
cout << "Please enter the number of days you will work: " << endl;
break;
case 'C':
cout << "Enter a letter: " << endl;
break;
case 'X':
break;
default:
cout << endl << "\a Invalid choice -- try again" << endl;
}
} while (choice != 'X');
return 0;
}
char display_menu()
{
char choice;
cout << endl << endl;
cout << " MAIN MENU" << endl;
cout << "A. Please enter a positive whole number: " << endl;
cout << "B. Please enter the number of days you will work: " << endl;
cout << "C. Enter a letter: " << endl;
cout << "X. Exit" << endl;
cout << "Make a choice: ";
cin >> choice;
return choice;
}
|