【问题标题】:how to see the printf when I debug the windows program? [duplicate]调试windows程序时如何查看printf? [复制]
【发布时间】:2012-06-24 15:32:49
【问题描述】:

可能重复:
c++ console in a non-console application project

我正在调试以 winmain 开头的 windows 程序。里面有 smome printf,我想知道我是否可以在某处查看 printf 输出?我需要一些特殊的工具吗?

【问题讨论】:

    标签: windows winapi mfc


    【解决方案1】:

    假设您使用的是 VC++,您可以使用 OutputDebugString 在 IDE 中显示输出。

    类似:

    wchar_t buffer[512]
    wsprintf(buffer, L"Value is %d\n", value);
    OutputDebugString(buffer);
    

    【讨论】:

      【解决方案2】:

      试试这个:

      AllocConsole();
      freopen("CONOUT$", "wb", stdout);
      // your printf()
      
      fclose(stdout);
      FreeConsole();
      

      【讨论】:

        猜你喜欢
        • 2010-10-09
        • 1970-01-01
        • 2012-03-23
        • 1970-01-01
        • 1970-01-01
        • 2012-06-22
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多