3

为什么我必须system("pause")在每个程序之后放置,否则我的程序运行但窗口只是闪烁并消失。在放置系统功能后,它会运行并提供一个按键继续的选项。我正在使用开发 C++ 4.9.9.2

4

2 回答 2

2

程序执行完毕。它没有其他事情可以做。

如果你愿意,你可以systemstd::cin.get();

于 2013-06-27T06:12:07.777 回答
1

I suppose you're using Windows so try this:

Either

  • make a shortcut for cmd.exe in the folder where your compiled binaries reside (make sure execute in [shortcut properties] is the current folder) or
  • hit Windows+R, type cmd, navigate to your executables directory using cd command

to obtain a windows command line window that will not close. Now you can use

Myexe.exe

an the window will remain open. (You can even clear it to have a fresh empty window by typing cls.)

Now you can terminate your program normally.

于 2013-06-27T06:25:32.443 回答