How do i get the screen to pause? [duplicate]

依然范特西╮ 提交于 2019-12-01 02:00:25

In Visual C++ you can either:

  • Put a breakpoint at the closing brace of main and run attached to the debugger (Debug -> Start Debugging). When the breakpoint is hit you will be able to view the console window.
  • Run detached from the debugger (Debug -> Start Without Debugging). When the application terminates, the console window will stay open with a "Press any key to continue..." prompt.

I usually use cin.getchar() to wait for a character.

Try adding system("PAUSE"); to the end of main before the return statement.

This executes the PAUSE system command which waits for a key to be pressed.

The easiest way is to wait for the user to press a key before returning from main.

You already have the answer in your code.. add another cin at the end of your program ;P user would have to press enter for program to continue and exit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!