How can you view printf output in a Win32 application (entering with a WinMain) in Visual Studio 2010?
Strictly answering your question, you may use printf-like functions in a Win32 application in Visual Studio 2010 using the winbase.h OutputDebugString
function.
I wrote a simple program that shows how to do it.
#include
#include
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdShow, int nCmdShow)
{
int number = 10;
char str[256];
sprintf_s(str, "It works! - number: %d \n", number);
OutputDebugString(str);
return 0;
}
The OutputDebugString
function takes an LPCSTR
as a parameter. I used the sprintf_s
to format the string before printing.
This would print the result to the Visual Studio 2010 output window.
I hope it helps!