C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 9th, 2015, 08:11 PM
Monarae Masters Monarae Masters is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2015
Posts: 1 Monarae Masters User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 25 sec
Reputation Power: 0
Syntax errors - I keep getting an error right after struct menu beverages

Code:
# include <stdlib.h>
# include <conio.h>
# include <stdio.h>
# include <string.h>

# define PASSWORD "employee"
# define MAXSIZE 20
# define MainCourse 1
# define Beverage 2
# define Pastry 3
# define Change 4
# define Receipt 5
# define Exit 6

// Structure of arrays
struct menu {
	char *name;
	int cost;
};

struct menu beverages []= {
	{"Hot Chocolate", 60},
	{"Coffee", 50},
	{"Soda", 75},
	{"Beer", 100},
	{"Water", 45},
	{NULL, 0}
}; 

static struct menu food []=
{
	{"Cheese Burger", 200},
	{"Fries", 80},
	{"Hot Dog", 150},
	{"Pancakes", 30},
	{"Fried Dumpling", 20},
	{"Eggs", 50},
	{"Sausage", 65},
	{"Fried Chicken", 100},
	{"Curried Chicken", 105},
	{"Stewed Chicken", 120},
	{"Rice and Peas", 150},
	{"Plain Rice", 110},
	{"Soup", 90},
	{NULL, 0}	
};

 static struct menu pastry []=
 {
 	{"Rock Cakes", 70},
	{"Gizzarda", 95},
	{"Fruit Cake", 200},
	{"Apple Pie", 300},
	{"Cheese Cake", 300},
	{"Fudge Cupcake", 100},
	{NULL, 0}
 };// End of array structure menu
 
 struct Stack
{
	int stk [MAXSIZE];
	int top;
}; typedef struct Stack STACK;

STACK s;

 
 
// Function display shows user the menu choices
void displayMenu(struct menu *mp)
{
	int i;
	struct menu *mpp;
	i=0;
	
	for(mpp = mp; mpp->name != NULL; ++mpp) 
	{
		printf("%d. %s. ", i, mpp->name);
		printf("Cost: $%d \n", mpp->cost);
		i++;
	}
}// End of function

//Structure getmenu regulates selection choices by user 
struct menu *getmenu(struct menu *mp, const char *prompt)
{
	int i, selection, order;
	char buffer [512];
	struct menu *mpp;
	
	FILE *cfPtr;
    if ((cfPtr= fopen ("Restaurant.txt", "a"))==NULL)
        printf ("File could not be opened\n");
   	
	while(1) 
	{
		fputs(prompt, stdout);
        fgets(buffer, sizeof buffer, stdin);
        if(sscanf(buffer, "%d", &selection) != 1)
                continue;
        if(selection < i)
                break;
    }
      return mp + selection;
 	  	                 	
}//End of structure

//Fucntion allows user to enter quantity of item chosen
int EnterQuantity ()
{
	int qty;
	printf ("Enter Quantity: ");
	scanf ("%d", &qty);
	return qty;
}

//function interface creates a user friendly display for user
void interface ()
{	
	 printf ("\t Welcome to Master's Restaurant and Bar!\n");
     printf ("\n");
	
	  printf ("                                          o8             \n");        
      printf ("                                          888            \n");             
      printf ("        ooo. .oo. .ooo.      ooo d8b      888oooo.       \n"); 
      printf ("        888P'Y88bP'Y88b      888''8p      d88' `88b      \n"); 
      printf ("        888   888   888      888          888   888      \n");   
      printf ("        888   888   888      888          888   888      \n");
      printf ("       o888o o888o o888o    d888b         `Y8bod8P'      \n");
 
}//End of Interface

/* Function Prototypes*/
void MenuInstructions (void);
void push ();
void search ();
int pop ();
void display ();
int stackExecution ();

// Function main begins program execution
int main ()
{
	struct menu *bev_s;
    struct menu *food_s;
    struct menu *past_s;
      
	interface ();
	int Mchoice, tableNum;
	char password[20];
	int count, fQuant, bQuant, pQuant, ch;
	int total, cashTender, change;
	
	count=3;

	for (int i=0; i<count; i++)
	{
		printf ("\n\t\tEnter the Password: ");
		scanf ("%s", password);
	
	    system ("cls");
	    
       	if (strcmp (password, PASSWORD)==0)
		{
		 	interface ();

            printf ("\n\t\tEnter the Client's Table number: ");
	        scanf ("%d", &tableNum);
	        
		    while (1)
		 	{ 
	            system ("cls");
            	interface ();
            	MenuInstructions ();
                
                scanf ("%d", &Mchoice);
 	  
 	            while ((ch = getchar()) != '\n' && ch != EOF);
 	            
            	switch (Mchoice) {

					case MainCourse:
					     system ("cls");		
					     printf ("\t.........Main Course............\n");
					     displayMenu(food);
					     food_s = getmenu(food, "\nSelect your main course: ");
					     fQuant= EnterQuantity();
					     getchar ();
        	    		 break;
 	  		
             		case Beverage:
             			 system ("cls");	
             			 printf ("\t.........Beverages.........\n");
             			 displayMenu(beverages);
             			 bev_s = getmenu(beverages, "\nSelect your beverage: ");
             			 bQuant= EnterQuantity();
             			 getchar ();
            		     break;
			
            		case Pastry:
            			 system ("cls");	
            			 printf ("\t.........Pastry.........\n");
            			 displayMenu(pastry);
            			 past_s= getmenu(pastry, "\nSelect your pastry: ");
            			 pQuant= EnterQuantity();
            			 getchar ();
            			 break;
            			 
            		case Change:
            			 system ("cls");
            			 total= (food_s->cost*fQuant) + (bev_s->cost*bQuant)+ (past_s->cost*pQuant);
           			     printf ("The total is %d\n", total);
           			     printf ("Enter Cash Tendered: ");
           			     scanf ("%d", &cashTender);
           			     change= cashTender- total;
           			     getchar ();
           			     break;
						 
           			case Receipt:     
           				 printf ("Items                     QTY         Price \n");
           				 printf ("%s                         %d         %d\n", food_s->name, fQuant, food_s->cost);
           				 printf ("%s                         %d         %d\n", bev_s->name, bQuant, bev_s->cost);
           				 printf ("%s                         %d         %d\n", past_s->name, pQuant, past_s->cost);
           				 printf ("______________________________\n");
           				 printf	("TOTAL                   $%d\n", total); 
           				 printf ("Cash Tendered           $%d\n", cashTender);
						 printf ("Change                  $%d\n", change);	       
					     getchar ();
           				break; 
           				
            		case Exit:	
					     exit (1);
						 break;
				
           			default:
         	             system ("cls");
         	             printf ("Invalid Choice\n\n");
         	             interface ();
         	             MenuInstructions ();
         	             getchar();
           	    	     break;
						  	
				    
    	        } // End Switch
    	        
    	        FILE *cfPtr;
          		if ((cfPtr= fopen ("Food.txt", "a"))==NULL)
         		{
               		printf ("File could not be opened\n");
         		}
         		
         		fprintf (cfPtr, "Total: %d\n", total);
    	        	
	    	 }//End while
             
        }//End if
         
         else
		
		//Controls the amount of times a user can enter an invalid password before the program closes
		printf ("Invalid Password!\n");
		count=count-1;
		printf ("You have %d tries left!\n", count);
		
    }//End For
    
    //Informs user of the end of the program	
	printf ("This program will close.\n");
	printf ("\n");

    getchar ();
} // end main


//Display Menu Instructions to User
void MenuInstructions ()
{	
	printf ("\n");
    printf ("---------------#Welcome to Main Menu#----------------\n");
    printf ("\n");
    printf ("\tPress 1 for Main Course\n");
	printf ("\tPress 2 for Beverage Menu\n");
    printf ("\tPress 3 for Pastry Menu\n");
    printf ("\tPress 4 to Calculate Change\n");
    printf ("\tPress 5 to Print Receipt\n");
    printf ("\tPress 6 to Exit\n");	
}  //End function instructions

int stackExecution ()
{
	int choice;
	 s.top= 1;
	 
	 printf (" STACK\n");
	 while (1)
	 {
	 	printf ("1 PUSH\n");
	 	printf ("2. SEARCH\n");
	 	printf ("3. POP\n");
	 	printf ("4. DISPLAY\n");
	 	printf ("5. EXIT\n");
	 	
	 	printf ("Enter Choice: \n");
	 	scanf ("%d",&choice);
	 	
	 	switch (choice){
	 		case 1:
	 			push();
	 			break;
	 			
	 		case 2:
			 search ();
			 break;
			 
			case 3:
			pop ();
			break;
			
			case 4:
			display ();
			break;
			
			case 5:
			exit (1);
			break; 	
	 	}// end switch function
	 	
	 	printf ("Type 0 to leave or 1 to continue\n");
	 	scanf ("%d", &choice);
	 }// end while
}// end function

void push ()
{
	int num;
	if (s.top== MAXSIZE-1)
	{
		printf ("Stack is Full\n");
		return;
	}
	else
	{
		printf ("Enter first total printed to file\n");
		scanf ("%d", &num);
		
		s.top= s.top+1;
		s.stk [s.top]=num;
	}// end if
	
	return;
}// end function

int pop()
{
	int num;
	
	if (s.top== -1)
	{
		printf ("stack is empty\n");
		return (s.top);
	}
	else
	{
		num= s.stk [s.top];
		printf ("Popped element is: %d\n", s.stk[s.top]);
		s.top= s.top-1;
	}
}// end function

void display ()
{
	int i;
	if (s.top== -1)
	{
		printf ("Stack is empty");
		return;
	}
	else
	{
		printf ("STACK\n");
		
		for (i=s.top; i<0; i--)
		{
			printf ("%d\n", s.stk[i]);
		}// end for
	}// end if
	printf ("\n");
}


Is it possible for anyone to compile it and tell me what the error is? My compiler doesn't tell me the errors, even when I uninstall and reinstall it. I just need to know what the error message says. Thank you in advance for your help.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Syntax errors - I keep getting an error right after struct menu beverages


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap