What is the Best Practice for Combating the Console Closing Issue?

前端 未结 10 1694
悲&欢浪女
悲&欢浪女 2020-11-27 22:21

After compiling console programs the console window closes immediately after running. What is the best practice for keeping it open? I\'ve searched google loads, I\'m used t

10条回答
  •  -上瘾入骨i
    2020-11-27 23:04

    A very common one is to just put in code to read a key from the console after your main application code closes. The keystroke read in just gets thrown away, but it holds the console open.

    It's not pretty, necessarily - but I often do this wrapped in a debug define, so during debugging, the console is held open. During release, I'm usually not running inside VS, and when run from a command line, this is no longer an issue.

提交回复
热议问题