Debug console for Win32 app

I keep forgetting this one so let me post it once and for all. Adding a debug console to a Win32 app takes 4 lines of code.

if(AllocConsole())
{
freopen(”CONOUT$”, “wt”, stdout);

SetConsoleTitle(L”Debug Console”);

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);
}

You can then printf your way out of trouble.

2 Responses to “Debug console for Win32 app”



  1. East Agent's Blog Says:

    Win32 APP 디버그 콘솔…

    Pierre Terdiman님이 자신이 블로그(Coder Conrner)에 올린 (초간단) Win32 App 디버그 콘솔 코드

    if(AllocConsole())
    {
    freopen(”CONOUT$”, “wt”, stdout);SetConsoleTitle(L”Debug Console”);SetConsoleTextAttribute(GetStdHand…

  2. ilian Says:

    And you can easily use something like VKDebug, that can show much more text in a text-field in a separate process, while also printing variable-names:

    int value1=7;

    print(value1); // this displays “value1 = 7″

shopfr.org cialis