Switch statement not working

I am working on a order system which starts with an initial menu called at main but when I try to return the first function by pressing one it is not moving from the menu. I have an item to ensure that the correct value is entered and I think this is why my case 1: is not being called although it has been defined.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include <iomanip.h>
#include <iostream.h>
#include <fstream.h>
#include <string.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <math.h>
#include <time.h>
#include <vector.h>
#include "derived.h"

void set_menu(void);
int get_option(int c,int r,int min,int max);
void message(int c,int r, char mess[]);
void press_key(int c, int r);

void set_menu(void)
{
 	clrscr();
   gotoxy(30,2); cout << "PRODUCT SYSTEM\n";
   gotoxy(30,3);cout << "--------------\n";
   gotoxy(30,4);cout << "1. Display Products\n";
   gotoxy(30,5);cout << "2. Update Products\n";
   gotoxy(30,6);cout << "3. Delete Products\n";
   gotoxy(30,7);cout << "4. Print Products\n";
   gotoxy(30,8);cout << "5. Display Orders\n";
   gotoxy(30,9);cout << "6. Update Orders\n";
   gotoxy(30,10);cout << "7. Delete Orders\n";
   gotoxy(30,11);cout << "8. Print Orders\n";
   gotoxy(30,12);cout << "9. Exit\n";
   gotoxy(30,15);cout << "Which Option 1-9 {_}";
}

int get_option(int c,int r)
{
	int x,min=1,max=9;
   do
   {
 		gotoxy(c,r);
   	cin >> x; //cin.ignore(10,'\n');
   	if((x < min) || (x > max))
   	{
   		message(30,17,"Invalid Option");
   	}
   }while((x<min)||(x>max));
   return x;
}

void message(int c,int r, char mess[])
{
 	char ch;
   gotoxy(c,r); cout << mess;
   gotoxy(c,r+1); cout <<"Press any key to continue ";
   ch = getche();
   gotoxy(c,r); cout <<"                                  ";
   gotoxy(c,r+1); cout << "                               ";
   gotoxy(30,15);cout << "Which Option 1-9 {_}";
}

void press_key(int c, int r)
{
 	gotoxy(c,r); cout << "Press any key to continue";
   getche();
}

void disOrder(void)
{
     clrscr();
	  cout << "display orders";
}

main()
{
	int option;

	do
   {
    	set_menu();

      option = get_option(48,15,1,9);
      switch(option)
      {
      	case 1 : disOrder(); break;
         case 2 : updOrder(); break;
         case 3 : delOrder(); break;
         case 4 : prtOrder(); break;
         case 5 : disProduct(); break;
         case 6 : updProduct(); break;
         case 7 : delProduct(); break;
         case 8 : prtProduct(); break;
      }

   }while(option !=9);

}


Can anyone see why the disOrder() function is not being called when I enter 1 as the option and it clearly states this should be called in the event of case 1:
You seem to be passing 4 args to your get_option(), even though it only takes 2...
yes i changed that as i thought that my min and max were causing an infitinte loop but i have put it back in again since
Topic archived. No new replies allowed.