C程序调试窗口控制台不会停留



我安装了适用于windows桌面的visual studio express 2013,并编写了第一个hello world程序。当我编译它时,它没有显示任何错误。当我点击本地窗口调试器按钮时,控制台窗口会闪烁1/4秒,然后消失。我该怎么做才能把它保持在那里,这样当我编写更长的代码时就不会有任何困难。

谢谢。

main()函数末尾添加system("pause");int x; scanf("%d", &x);是常用选项。

使用Microsoft Visual Studio 2013编译C程序时,请在程序中使用以下模板:

//#define _CRT_SECURE_NO_WARNINGS
// un-comment the line above, if you want to
// be able to use functions like scanf instead
// of their more secure versions like scanf_s
#include <stdio.h>

int main( /* int argc, char ** argv */ ) {

    fflush( stdin );
    getchar( );
    return 0;
}

这是MSVC 2013可以使用的最简单的模板。不要在其他任何地方使用fflush( stdin );,它在其他地方没有定义的行为,它是微软特有的。

最新更新