How can you view printf output in a Win32 application (entering with a WinMain) in Visual Studio 2010?
I know that I have done this in the past using the AllocConsole function, but I also recall that it was just a little trickier than I expected.
A quick Google search on AllocConsole yields what is apparently a Windows Developer Journal article that seems relevant. From there, the following seems similar to what I recall, vague as it is.
void SetStdOutToNewConsole()
{
int hConHandle;
long lStdHandle;
FILE *fp;
// Allocate a console for this app
AllocConsole();
// Redirect unbuffered STDOUT to the console
lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
fp = _fdopen(hConHandle, "w");
*stdout = *fp;
setvbuf(stdout, NULL, _IONBF, 0);
}