On Thu, Apr 04, 2002, mulix wrote about "Re: c question":
> On Thu, Apr 04, 2002 at 06:17:16PM +0300, Nadav Har'El wrote:
> stdout = fopen("/my/logging/file");
> stderr = fopen("/my/other/logging/file");
Ok, I get your point. I don't remember seeing any program doing something
like that, but I guess it's conceivable, and that using fileno() might be a
wise idea.
One last point though: it is not portable to assign to stdout, etc. like
you showed above. In Linux you can do this, because stdout is defined as
extern FILE *stdout; /* Standard output stream. */
but in other UNIX systems you can't. For example, in Solaris (8, at least),
and in all AT&T-based systems I knew, stdout is defined as
#define stdout (&__iob[1])
And you obviously cannot assign to this. You may, perhaps, do
*stdout=*fopen(...);
but that is really funky and again non-portable; Instead, the portably ANSI-
C solution is to use the freopen() function.
--
Nadav Har'El | Thursday, Apr 4 2002, 23 Nisan 5762
[EMAIL PROTECTED] |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |Unlike Microsoft, a restaurant will not
http://nadav.harel.org.il |ask me to pay for food with a bug in it!
=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]