#include<stdio.h>
#include<ctype.h>
#define maxstring 30
struct menuItemType
{
char menuList[20];
float amount;
}menuList;
void showmenu();
void add();
void readfile();
char *stringcapitalize(char*);
char buffer[maxstring + 1];
void main()
{
showmenu();
getche();
}
void showmenu()
{
int choice;
printf("Local restaurant");
printf("1. Add Order");
printf("2. Read Complete File");
printf("3. Exit");
printf("Enter your choice:");
scanf("%d",&choice);
switch(choice)
{
case1;
add();
break;
case 2;
readfile();
break;
case 3;
exit(0);
}
}
void add();
{
char choice1;
int i,num;
float amount;
float total;
printf("Enter Number of Orders\n");
scanf("%d", &num);
for (i=0;i<num;i++)
{
fprintf("MENU LIST\n");
fprintf("Plain Egg $1.45\n");
fprintf("Bacon and Egg $2.45\n");
fprintf("Muffin $0.99\n");
fprintf("French Toast $1.99\n");
fprintf("Fruit Basket $2.49\n");
fprintf("Cereal $0.69\n");
fprintf("Coffee $0.50\n");
fprintf("Tea $0.75\n");
'
fprintf("Enter Your Order:\n");
FILE *pf;
pf=fopen("D:\\record.txt","a");
gets(menuList.menuList);
cout<<end];
fprintf("Enter Amount\n");
fscanf("%.2f",&amount);
fprintf(pf,"\n%.2f",amount);
fwrite(&menuList, sizeof(mwenuList),5,pf);
fclose(pf);
}
for (i=1;i<num;i++)
{
printf("%s\n", stringcapitalize(menuList.menuList));
}
printf("\nDo you wish to add onother set of order? (y||n)");
scanf("%c", &choice1);
switch(choice1)
{
case 'y':
case 'Y':
add();
break;
default:
showmenu();
void readfile();
{
int i,num;
FILE *pf;
pf=fopen("D:\\record.txt","r");
if((pf=fopen("D:\\record,txt","r"))==NULL)
fprintf("could not open file");
}
while(fread(&menulist,sizeof(menulist),1,pf)==1)
{
printf("%s\n", stringcapitalize(menulist.menilist));
}
fclose();
getch();
showmenu();
}
char *
stringcapitalize(char *string)
{
char *cp;
cp=string;
*cp=toupper(*cp);
++cp;
while(*cp!='\O')
{
*cp=tolower(*cp);
++cp;
}
return(string);
}