Simple way to send debug information to the Visual Studio 'Output' window

Jim Fell picture Jim Fell · Mar 2, 2012 · Viewed 15.7k times · Source

I started a blank project in Visual Studio 2010 to write a C application. How can I send debug information to the Output window (menu Debug -> Windows -> Output )? Is there a relatively simple way to implement TRACE or OutputDebugString or something similar?

Answer

Mike Clark picture Mike Clark · Mar 2, 2012

You can use OutputDebugString from a VS C program.

#include <windows.h>

int _tmain(int argc, _TCHAR* argv[])
{
    OutputDebugString(_T("Hello World\n"));
    return 0;
}

The output will only be visible if you run with debugging (Debug > Start Debugging)

In the Output window, select "Debug" for "Show output from:"