David Ling
David Ling

Reputation: 145

Disappearing Console window when coding c++ in visual studio

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

Answers (2)

selbie
selbie

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".

enter image description here

Upvotes: 1

Md Golam Rahman Tushar
Md Golam Rahman Tushar

Reputation: 2385

Simply add getch(); before the return statement. It will then wait for you to press any button to close.

Upvotes: 1

Related Questions