On Thu, Apr 04, 2002, Shlomi Fish wrote about "Re: c question":
> When I worked in Smart-Link and asked a more experienced fellow programmer
> how I can, in the Win32 RTL, convert an open() filehandle to its Windows
> HFILE equivalent, he told me that mixing IO for two different kinds of
> handles is usually a bad idea. Then he told me about the stdio.h/open()
> side-effects.

In Unix, there's fdopen() to "convert" an open file descriptor into an
stdio FILE *. It's not terribily useful (so I'd guess most of you never heard
of this function, let alone used it), but it comes in handy in certain rare
cases where some system call or function returns a file descriptor (e.g.,
accept()), but you prefer to work on it using stdio.

Whenever you mix stdio and file descriptors (or stdio and C++ streams, or
the three of them :)), you'll have to know what you're doing, and think of
what kind of buffering might happen, and what might the consequences be.
Generally, unless you're a quite experienced programmer, such mixing would
be an outright mistake (like using a single write() in an otherwise stdio-
using program because you didn't want buffering - instead of correctly
calling fflush()).

-- 
Nadav Har'El                        |      Thursday, Apr 4 2002, 23 Nisan 5762
[EMAIL PROTECTED]             |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |I want to be a human being, not a human
http://nadav.harel.org.il           |doing -- Scatman John

=================================================================
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]

Reply via email to