【问题标题】:C program debug window console won't stay [duplicate]C程序调试窗口控制台不会停留[重复]
【发布时间】:2014-05-27 04:29:05
【问题描述】:

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

谢谢。

【问题讨论】:

  • 转到调试菜单->按 StartWithoutDebugging - 完成...

标签: c


【解决方案1】:

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

【讨论】:

  • 我认为 C 中没有 cin
【解决方案2】:

每当您使用 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 );,它在其他地方没有定义的行为,它是 microsoft 特定的。

【讨论】:

    猜你喜欢
    • 2017-03-29
    • 1970-01-01
    • 2016-03-30
    • 2019-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-17
    • 1970-01-01
    相关资源
    最近更新 更多