How do I reset an integer once I've set it?

Basically, I'm trying to make it so when I press the wrong key it takes me straight back and makes me choose again but it doesn't change the int back to nothing. If I pressed 'a' or something not listed it should tell me its an incorrect choice and then make me choose again so I can only choose what's listed but it will then keep coming up with its incorrect until I close the program! How do I fix this?

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
#include<iostream>
using namespace std;

int main()
{
Main_Menu:
system("CLS");
int Choice;
		
cout << "**************************************************" << endl;
cout << "* Main Menu                                      *" << endl;
cout << "*                                                *" << endl;
cout << "*                1)Start Game                    *" << endl;
cout << "*                2)Exit                          *" << endl;
cout << "*                                                *" << endl;
cout << "**************************************************" << endl;
cin >> Choice;
		
if(Choice==1)
{
	cout << "Start the game!" << endl;
	system("PAUSE");
	//start game
	return 0;
}

if(Choice==2)
{
	cout << "Goodbye!" << endl;
	system("PAUSE");
	return 0;
}

else
{
	cout << "That was not a valid choice please choose again!" << endl;
	system("PAUSE");
	goto Main_Menu;
}		
return 0;
}
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include <iostream>
#include <string>
using namespace std;

//----------------------------------------------------------------------------
// http://www.cplusplus.com/articles/4z18T05o/#Windows
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <windows.h>

void ClearScreen()
{
  HANDLE                     hStdOut;
  CONSOLE_SCREEN_BUFFER_INFO csbi;
  DWORD                      count;
  DWORD                      cellCount;
  COORD                      homeCoords = { 0, 0 };

  hStdOut = GetStdHandle( STD_OUTPUT_HANDLE );
  if (hStdOut == INVALID_HANDLE_VALUE) return;

  /* Get the number of cells in the current buffer */
  if (!GetConsoleScreenBufferInfo( hStdOut, &csbi )) return;
  cellCount = csbi.dwSize.X *csbi.dwSize.Y;

  /* Fill the entire buffer with spaces */
  if (!FillConsoleOutputCharacter(
    hStdOut,
    (TCHAR) ' ',
    cellCount,
    homeCoords,
    &count
    )) return;

  /* Fill the entire buffer with the current colors and attributes */
  if (!FillConsoleOutputAttribute(
    hStdOut,
    csbi.wAttributes,
    cellCount,
    homeCoords,
    &count
    )) return;

  /* Move the cursor home */
  SetConsoleCursorPosition( hStdOut, homeCoords );
}

//----------------------------------------------------------------------------
// Pause on quit
// http://www.cplusplus.com/forum/lounge/171162/
#ifdef _WIN32
  #include <iostream>
  #include <string>
  #ifndef NOMINMAX
  #define NOMINMAX
  #endif
  #include <windows.h>
  struct pause_on_quit { bool is_console_owner; pause_on_quit() { 
  FreeConsole(); is_console_owner = !AttachConsole( ATTACH_PARENT_PROCESS );
  if (is_console_owner) AllocConsole(); } ~pause_on_quit() { if 
  (is_console_owner) { std::cout << "All done. Press ENTER or close the "
  "window."; FlushConsoleInputBuffer( GetStdHandle( STD_INPUT_HANDLE ) ); 
  std::string s; std::getline( std::cin, s ); } } } Z201508081318;
#endif 

//----------------------------------------------------------------------------
enum MainMenuChoice { mmStartGame, mmExit };

MainMenuChoice MainMenu()
{
  ClearScreen();
  string s;
  
  cout << 
    "**************************************************\n"
    "* Main Menu                                      *\n"
    "*                                                *\n"
    "*                1)Start Game                    *\n"
    "*                2)Exit                          *\n"
    "*                                                *\n"
    "**************************************************\n";
    
  string prompt = "Choose> ";
  while (true)
  {
    cout << prompt;
      
    getline( cin, s );
    switch (s.c_str()[0])
    {
      case '1': return mmStartGame;
      case '2': return mmExit;
    }
    
    prompt = "Invalid. Choose again> ";
  }
}

//----------------------------------------------------------------------------
void PlayGame()
{
  ClearScreen();
  cout << "\n\nPut gameplay here.\nPress ENTER to return to Main Menu.\n";
  string s;
  getline( cin, s );
}

//----------------------------------------------------------------------------
int main()
{
  // Initializations go here

  // Main loop
  bool done = false;
  while (!done)
  {
    switch (MainMenu())
    {
      case mmStartGame: PlayGame(); break;
      case mmExit:      done = true; break;
    }
  }
  
  // Finalizations go here
  cout << "Goodbye!\n";
}

Hope this helps.
Thankyou very much i've fixed it now!
Topic archived. No new replies allowed.