skip to Main Content

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

2

Answers


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

    Login or Signup to reply.
  2. Try adding this in the last place.

    system("pause");
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search