Visual C++ Enable Console

前端 未结 3 1628
长情又很酷
长情又很酷 2020-12-14 12:41

I created an Empty Project in Visual C++, but now I need the Console to display debug output.

How can I enable the Console without recreating the project or show the

3条回答
  •  情深已故
    2020-12-14 13:05

    Here's some code you can insert to get a console window in a GUI'd windows app that starts in WinMain. There are other ways to accomplish this but this is the most compact snippet I've found.

    //Alloc Console
    //print some stuff to the console
    //make sure to include #include "stdio.h"
    //note, you must use the #include / using namespace std
    //to use the iostream... #incldue "iostream.h" didn't seem to work
    //in my VC 6
    AllocConsole();
    freopen("conin$","r",stdin);
    freopen("conout$","w",stdout);
    freopen("conout$","w",stderr);
    printf("Debugging Window:\n");
    

提交回复
热议问题