Reputation: 145
Im having a technical issue while trying to code C++ in visual Studio. My code was working fine until it required me to use input from the user, so i coded a simple program like the one below
int chairs(void) {
int count;
cout << “Enter the number of chairs: “;
cin >> count;
return count;
}
When i run the code the console window opens and allows the user to enter the number of chairs, however, once the value has been entered the window immediatly closes and theres no output in visual studios own console window. How can i fix this issue? is there a certain plug-in or settings i need to change? I knoww you can code your own settings in user settings. Thankyou
Upvotes: 0
Views: 127
Reputation: 104589
From the main menu, select Tools,then Options.
Make sure this setting is not enabled under Debugging: "Automatically close console window when debugging stops".
Upvotes: 1
Reputation: 2385
Simply add getch(); before the return statement. It will then wait for you to press any button to close.
Upvotes: 1