"noleander" <no*******@discussions.microsoft.com> wrote in message
news:3D**********************************@microsof t.com...
Sorry if this is a trivial question :-)
I've got several print statements in my code:
fprintf ( stderr, ....);
but when I run my program, I cannot find the output text in any window.
My program is in Visual C++. The program is windows-based (not a
command-line program. The program is not managed. I'm running within
the
Visual C++ debugger. I've tried displaying every Vis C++ window,
including
the "Output" window, but the fprintf() text does not appear there.
What window contains the fprintf(stderr) text (when running in the
debugger)?
Windows programs do not have consoles by default. Consoles are the devices
to which stdout and stderr are usually wired. Catch 22.
If you want to see output in the debugger you can use OutputDebugString().
If you want a console for debugging your windows applications you can do
this:
FILE *fp;
HANDLE hCon;
// Allocate a console
AllocConsole();
// And make printf happy
hCon = GetStdHandle(STD_OUTPUT_HANDLE);
fd = _open_osfhandle(reinterpret_cast<long>(hCon), 0);
fp = _fdopen(fd, "w");
*stdout = *fp;
setvbuf(stdout, NULL, _IONBF, 0);
Regards,
Will