473,396 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 3623
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: clusardi2k | last post by:
/* The below code on SGI will wait for you to enter 2 things, but on Linux it will only wait the first time. I can make the code work by replacing the scanf with: char data ; fgets...
5
by: L. Westmeier | last post by:
Reading the man pages and some code did not really help me in understanding the difference between - or better when I should use - perror("...") and fprintf(stderr, "...") Any hint or help is...
3
by: Andrew Fabbro | last post by:
I have code with stuff like this all over it: sprintf(errmsg,"somefunc(): %s has illegal character %c",somestring,somechar); fatal_error(errmsg); where fatal_error() just fprintf's to stderr...
1
by: David Resnick | last post by:
I had a problem going from gcc 2.96 to gcc 3.2.3 and narrowed it down to the following code. The question is whether the problem is undefined behavior on the code's part or a compiler bug. ...
7
by: jchludzinski | last post by:
I tryin' to print out a string with a variable number of blanks/spaces preceding the string. I know that if I use: fprintf( stdout, "%12s", string ); I get 12 blanks preceding 'string'. If I...
89
by: Cuthbert | last post by:
After compiling the source code with gcc v.4.1.1, I got a warning message: "/tmp/ccixzSIL.o: In function 'main';ex.c: (.text+0x9a): warning: the 'gets' function is dangerous and should not be...
18
by: praetor.michael | last post by:
I have a DLL written in C that writes to stderr. I have a win32 console application that makes calls to the DLL. In the console app I redirect stderr to a file using freopen. The problem I'm...
6
by: Chad | last post by:
When the following functions takes the string "this is a string" static void *build_string(char *s) { int k; char *start; size_t len; size_t max; len = strlen(s);
45
by: loudking | last post by:
Hello, all I don't quite understand what does ((time_t)-1) mean when I execute "man 2 time" RETURN VALUE On success, the value of time in seconds since the Epoch is retu rned. On error,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.