我怎样才能让控制台,与输出,不会在程序结束后VS 2010年快车C++?我怎样才能使控制台,输出,不会在VS 2010程序结束后消失C++
我写在c中,而不是在c + +,所以我需要一个函数,并包括路径库。
谢谢
我怎样才能让控制台,与输出,不会在程序结束后VS 2010年快车C++?我怎样才能使控制台,输出,不会在VS 2010程序结束后消失C++
我写在c中,而不是在c + +,所以我需要一个函数,并包括路径库。
谢谢
按下Ctrl + F5(“Build - > Start Without Debugging”)会运行应用程序并在关闭控制台之前自动等待按键。但是,正如名称所示,您没有附加调试器。
您可以简单地轮询输入。这会执行一个块,以便该功能只在用户提供更多输入时才会返回 - 通常输入。如果你在Windows上,你也可以使用系统(“暂停”)。
您有几种选择:
getchar()
你从主回来之前。system("pause")
你从主int waitforenter(void) {
int ch;
puts("press ENTER (maybe twice)");
/* get rid of a (possibly) pre existing '\n' */
do {
ch = getchar();
} while ((ch != EOF) && (ch != '\n'));
/* and again */
if (ch != EOF) do ch = getchar(); while ((ch != EOF) && (ch != '\n'));
return ch;
}
返回,然后右键你main()
函数结束之前调用waitforenter()
之前。
如果已有用户输入,则必须轮询两次。 – Wok 2010-09-16 12:52:36