C++ beginner, execution window disappears quickly

前端 未结 7 1825
我寻月下人不归
我寻月下人不归 2020-12-11 11:50

I am a beginner in C++ and I was trying to write a program that finds the average of two numbers, but when I run the program, the window disappears without allowing me to se

7条回答
  •  孤城傲影
    2020-12-11 12:37

    Solution #0 (proper):
    Run program from shell (cmd.exe, bash)

    Solution #1 (proper):
    Run program from orthodox file manager. Far Manager or midnight commander.

    Solution #2 (alternative);
    Redirect output to file. program.exe >file.txt from command line.

    Solution #3 (improper):
    Launch message box, use "sleep"/"Sleep" to delay program termination.

    Solution #4 (improper):
    Request user input at the end of program.

    Solution #5 (improper):
    Set breakpoint on "return 0", debug the program.

    Solution #6 (windows+msvc):
    Launch program from msvc by Ctrl+F5 using debug build. You'll get "press key to continue" prompt.

提交回复
热议问题