473,804 Members | 3,228 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3651
"noleander" <no*******@disc ussions.microso ft.com> wrote in message
news:3D******** *************** ***********@mic rosoft.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 OutputDebugStri ng().

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(ST D_OUTPUT_HANDLE );

fd = _open_osfhandle (reinterpret_ca st<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 OutputDebugStri ng() 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
639
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 (data,5,stdin); the_number = atoi (data);
5
12658
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 appreciated. L. Westmeier
3
3165
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 and exits. I'd like to change the above to something like: fatal_error("somefunc(): %s has illegal character
1
1839
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. #include <stdlib.h> #include <stdio.h> struct frob { char a; int b;
7
1419
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 use: n = 12; fprintf( stdout, "%(n)s: ", string );
89
6090
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 used." Could anybody tell me why gets() function is dangerous?? Thank you very much. Cuthbert
18
9264
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 having is that none of the messages sent to stderr from the DLL are getting written to the file but if I write to stderr from the console application it gets written to the file no problem. Any ideas??
6
1808
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
9454
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, ((time_t)-1) is returned, and errno is set
0
9708
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9588
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10589
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10340
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3828
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2999
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.