-----restaurant menu-----

i want to make a restaurant menu. The following code are listed below.


#include <stdio.h>
#include <afxcoll.h>
#include <malloc.h>

typedef struct {
CString key;
CString item0;
CString item1;
} RECORD;


CMapStringToPtr db_table;

int display_menu()
{ int ch;
do
{
printf("\n\nSimple XXX Data Base Menu:\n");
printf("1. Input new record\n");
printf("2. Examine record based on name\n");
printf("3. List all records\n");
printf("4. Remove record\n");
printf("5. Edit record\n");
printf("6. Save file\n");
printf("7. Load file\n");
printf("\n");
printf("0. Exit \n");
printf("\n\nSelection: ");
fflush(stdin);
scanf("%d", &ch);
if (ch <= 7 && ch >= 0) break;
else printf("\aInvalid input\n");
} while (TRUE);
return ch;
}

void input_record(void)
{
char inKey[30], inItem0[12], inItem1[30];
RECORD *p;

printf("Input new record\n");
printf("\nKey: ");
scanf("%s", inKey);
printf("\nItem0: ");
scanf("%s", inItem0);
printf("\nItem1: ");
scanf("%s", inItem1);
p = new RECORD;
(*p).key = inKey;
(*p).item0 = inItem0;
(*p).item1 = inItem1;
db_table.SetAt(inKey, (void *) p);
printf("Record %s with item0:%s and item1:%s added.\n", (*p).key, (*p).item0, (*p).item1 );
}

void examine_record(void)
{
char inKey[30];
RECORD *p;

printf("Examine record based on name\n");
printf("\nEnter key to be examined: ");
scanf("%s", inKey);
if ( db_table.Lookup(inKey, (void * &) p) )
{
printf("\n%s: Item0=%s , Item1=%s\n", inKey, (*p).item0, (*p).item1);
}
else printf("\n%s record NOT found.\a", inKey);
}

void list_all_record(void)
{
POSITION dbPos;
CString dbKey;
RECORD *dbPtr;

printf("List all records\n");
printf("Key\t Item0\t Item1\n");
printf("---\t -----\t -----\n");

{

printf("%s\t %s\t %s\n", dbPtr->key, dbPtr->item0, dbPtr->item1);
}
}

BOOL take_action(int choice)
{ BOOL returncode=TRUE;
char ch;

printf("perform(%d) is called.\n", choice);
switch (choice)
{
case 0: printf("Are you sure to exit (Y/N)? ");
fflush(stdin);
scanf("%c", &ch);
returncode = toupper(ch) != 'Y';
break;
case 1: input_record();
break;
case 2: examine_record();
break;
case 3: list_all_record();
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
default: printf("\n ***** perform(%d) is called illegally.\n\a\a", choice);
break;
}
return returncode;
}

void main(void)
{
int choice;
BOOL next_choice;

do
{
choice=display_menu();
next_choice=take_action(choice);
} while (next_choice);
printf("\nProgram exit.\n");
}

i want to make a restaurant menu. The following code are listed below.
and that is what you want to tell us?
Topic archived. No new replies allowed.