So I've been having long nights and extreme headaches over my program. I have my main function which is the menu. Then im adding my entrees as their own thing below that. I am pretty sure i need a function prototype or a function call or something else to fix my problem but im not sure as to what i need to add or take out. I need to get my entrees to return to the main, but it just wont happen. Please help and before you post telling me to us "cout<<" and all of the things related to iostream or whatnot im not able to because of the older versions of c++ we use. Also ive opt outed the code im not using i just want to get the one entree working before i change all of the code. So please help me with getting the biscuits and gravy option to return to main and print there. Thanks in advance.

#include "stdafx.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "iostream.h"

// Function main begins
// program execution

int main() {
  
  int choice = 0 ;

  int bill = 0 ;

  int drinks = 0 ;

  int entrees = 0 ;

  int newspaper = 0 ;

  int sides = 0 ;

  int specials = 0 ;

  int takeout = 0 ;
    
  int biscuitsandgravy = 0 ;
    
  int burrito = 0 ;
    
  int waffles = 0 ;
    
  int omelets = 0 ;
    
  int cereal = 0 ;
    
  int eggs = 0 ;
    
  int breakfastsandwich = 0 ;
    
  int pancakes = 0 ;
    
  int bagel = 0 ;
    
  int chorizoandeggs = 0 ;

  printf("Welcome to Hashbrowns!\n") ;
  printf("What part of the menu would you like to see?\n") ;

  printf("1 - Specials\n") ;
  printf("2 - Drinks\n") ;
  printf("3 - Entrees\n") ;
  printf("4 - Newspaper\n") ;
  printf("5 - Sides\n") ;
  printf("6 - Takeout or Dine in\n") ;
  printf("7 - Bill\n") ;
  printf("Your decision -> ") ;
  scanf("%d",&choice) ;

  switch(choice) {

    case 1 :
	  specials++ ;
	  printf("Specials:\n") ;
	  break ;	
		
    case 2 :
      drinks++ ;
	  printf("Drinks:\n") ;
      break ;

    case 3 :
      entrees++ ;
      printf("Entrees:\n") ;
      break ;

    case 4 :
      newspaper++ ;
	  printf("Newspaper:\n") ;
      break ;

    case 5 :
      sides++ ;
	  printf("Sides:\n") ;
	  break ;	 

	case 6 :
	  takeout++ ;
      printf("Takeout?\n") ;
	  break ;	 
		
	case 7 :
	  bill++ ;
	  printf("Bill:\n") ;
	  break ;	 
	 
  } // End switch

  return choice ;

}

int entrees () {
    
  int choice = 0 ;

  int biscuitsandgravy = 0 ;
    
  if(entrees) {

    printf("1 - Biscuits and Gravy: $1.50\n") ;
    printf("2 - Burrito: $2.50\n") ;
    printf("3 - Waffles: $2.00\n") ;
    printf("4 - Omelets: $3.25\n") ;
    printf("5 - Cereal: $1.99\n") ;
    printf("6 - Eggs: $1.00\n") ;
    printf("7 - Breakfast Sandwich: $2.99\n") ;
    printf("8 - Pancakes: $2.50\n") ;
    printf("9 - Bagel: $.50\n") ;
    printf("10 - Chorizo and Eggs: $3.00\n") ;
    printf("Your decision -> ") ;
    scanf("%d", &choice) ;

      switch(choice) {

      case 1 :
        biscuitsandgravy = 0 ; // execute subroutine biscuitsandgravy
	    printf("Biscuits and Gravy: $1.50\n") ;
        break ;
/*
      case 2 :
	    burrito ;
        printf("Burrito: $2.50\n") ;
	    break ;

      case 3 :
	    waffles ;
        printf("Waffles: $2.00\n") ;
	    break ;

      case 4 :
	    omelets ;
        printf("Omelets: $3.25\n") ;
	    break ;

      case 5 :
	    cereal ;
        printf("Cereal: $1.99\n") ;
	    break ;

      case 6 :
	    eggs ;
        printf("Eggs: $1.00\n") ;
	    break ;

      case 7 :
	    breakfastsandwich ;
        printf("Breakfast Sandwich: $2.99\n") ;
	    break ;

      case 8 :
	    pancakes ;
        printf("Pancakes: $2.50\n") ;
	    break ;

      case 9 :
	    bagel ;
        printf("Bagel: $.50\n") ;
        break ;

      case 10 :
	    chorizoandeggs ;
        printf("Chorizo and Eggs: $3.00\n") ;
        break ;
*/

	  } // End switch

  } // End Entrees

  return choice ;
  
  // Indicates that program ended
  // successfully
} // End function main

Recommended Answers

All 9 Replies

//...
73 case 3 :
74      entrees++ ;
75      printf("Entrees:\n") ;
76      break ;
//...

There's no call to entrees() here... You need to actually call the function, then store the return value.

Some info on functions.

That's the problem tho I cant do that. Every time I have tried something I get errors out the booku and im just not sure how to do this right.

And also the link you provided i can not use because i am unable to use "cout<< and cin<<" as i have said in the beginning but thank you anyways.

Is this C or C++? There is a difference. Your code looks more like C.

Also, I notice that you have a #include for "stdafx.h". That header only appears in Win32 projects on MS Visual Studio. What version of Visual Studio are you using?

Just set the cin/cout issue aside, the link I gave you has nothing to do with them. Sure, the functions demonstrated include them, but that doesn't mean that you have to include them in yours. It explains how to write and call functions, which is what you need to figure out.

Please help and before you post telling me to us "cout<<" and all of the things related to iostream or whatnot im not able to because of the older versions of c++ we use.

Then you are writing C, not C++. There is no C++ compiler that cannot use cout . It's part of the language.

And if you aren't allowed to use "iostream or whatnot", why are you including it?

it is a win32 project and it is in ms visual studio v 6 i believe sorry i didnt post that im new to this and was unaware of that. I have seen some examples of calls in other programs like my example below. Im not sure if this is the call needed and if it is how to place it to make it work.

for( x=0 ; x <= 7 ; x++ )

remember, post your C code in the C section of the forums. This code is definitely C. This is the C++ Forum

it is a win32 project and it is in ms visual studio v 6 i believe sorry i didnt post that im new to this and was unaware of that. I have seen some examples of calls in other programs like my example below. Im not sure if this is the call needed and if it is how to place it to make it work.

for( x=0 ; x <= 7 ; x++ )

That's not a function call, that's a for loop header.

It is c++ code not c code...I may be using a similar code but is definitly c++, im just using a computer that doesn't have iostream or isostream library's so that we can not purposefully use them...

commented: There is no such thing as a C++ compiler that does not have iostream. They do NOT exist. This is C. -3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.