alrite im kinda new to C++ and im starting to write small games and when i made my menu script it started good where you had to enter the number to which level of difficulty you want then when u put in the number and hit enter it runs through the rest of the script super fast and exits the screen so can i get some help here heres the script
// Menu Chooser
// Demonstrates the switch statement
#include <iostream>
using namespace std;
int main()
{
cout << "Difficulty Levels\n\n";
cout << "1 - Easy\n";
cout << "2 - Normal\n";
cout << "3 - Hard\n\n";
int choice;
cout << "Choice: ";
cin >> choice;
switch (choice)
{
case 1:
cout << "You picked Easy.\n";
break;
case 2:
cout << "You picked Normal.\n";
break;
case 3:
cout << "You picked Hard.\n";
break;
default:
cout << "You made an illegal choice.\n";
}
return 0;
}
ok this is it so far but then i thought it would work if i did this
// Menu Chooser
// Demonstrates the switch statement
#include <iostream>
using namespace std;
int main()
{
cout << "Difficulty Levels\n\n";
cout << "1 - Easy\n";
cout << "2 - Normal\n";
cout << "3 - Hard\n\n";
int choice;
cout << "Choice: ";
cin >> choice;
switch (choice)
{
case 1:
cout << "You picked Easy.\n";
break;
case 2:
cout << "You picked Normal.\n";
break;
case 3:
cout << "You picked Hard.\n";
break;
default:
cout << "You made an illegal choice.\n";
}
std::cout << "press the enter key to exit";
std::cin.ignore(std::cin.rdbuf()->in_avail() +1);
return 0;
}
but it didnt so does anyone know how to stop this thanks