0

I don't understand. I wrote a "hello world" program and run it, console only shows up immediately and turns itself off. I enter 5 case in console, but when i press "5", ENTER, the console not printing the fifth case, it's turn off :> You guys can help me please This is my launch.json

I want to use vscode console to input the result then print it with the line "press any key to countinue" like DevC++. I want it to not turn itself off when I haven't entered all the cases

  • I'm not familiar with vscode, but a simple work around would be adding `while(true){}` as the last line of your main function. This will make the program run forever, until you press CTRL+C – Cedric Martens Nov 04 '22 at 04:58

2 Answers2

0

After your while loop, add: _getch();

std::cout << "press any key to countinue...";
int c = _getch();

Then the application will wait untill you press a key.

What's happening is when the caSe is zero the application leaves the loop. Then there is no code left and the application exits.


But please remove the second image and replace the first with your code. We love to copy your code to help you out. The programs output you should write out too, although in this case not needed when you write clearly what is happening. And state clearly what you want to do.

Willem
  • 302
  • 10
0

Try adding this in the last place.

system("pause");