Using Switch Case and It would not execute

I would appreciate the Help. The code would not execute. I tried to see what is wrong with playmultiplayer but I could not get it. In case 3 there an error when I execute.



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


# include <iostream>

 using namespace std;

  void playgame ()
  {
       cout << "play game called";
  }
 void loadgame ()
 {
     cout << "Load Game Called:";

 }

  void playmultplayer ()
  {
      cout << "play multiplayer game called";
  }

   int main ()
   {
       int input;

       cout << "1. Play Game\n";
       cout << "2. Load Game\n";
       cout << "3. Playmultiplayer\n";
       cout << "4. Exit\n";
       cout << "Selection: ";
       cin >> input;

       switch ( input ){
       case 1:
       playgame ();
       break;
       case 2:
       loadgame ();
       break;
       case 3:
       playmultiplayer();
       break;
       case 4:
       cout <<"Thank You for playing!\n";
       break;
       default:
       cout << "Error, bad input, quitting\n";
       break;

       }
       cin.get();
   }
Last edited on
You have "multiplayer" written differently for the function and the switch statement case. Change line 17 to
void playmultiplayer()
Thanks alot!
Topic archived. No new replies allowed.