469,307 Members | 2,064 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,307 developers. It's quick & easy.

Where does fprintf(stderr, ..) go to?

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)?

Nov 17 '05 #1
2 3385
"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
Nov 17 '05 #2
Thanks for the prompt and accurate reply.

Using OutputDebugString() works perfectly for me!
Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

21 posts views Thread by clusardi2k | last post: by
5 posts views Thread by L. Westmeier | last post: by
3 posts views Thread by Andrew Fabbro | last post: by
1 post views Thread by David Resnick | last post: by
7 posts views Thread by jchludzinski | last post: by
18 posts views Thread by praetor.michael | last post: by
45 posts views Thread by loudking | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.