Q:

Derive stdio FILE handle from ostream (stdout)

I am using cout/ostream in a c++ project.  But it relies on a C project that uses stdio (FILE).
So I want to write a function like
void MyLog(ostream output) {
   OLD_UGLY_C_FUNCTION(ostream.toStdio());
}

Is that possible?  In pre C++11?

A:

The point is the system and compiler dependants. You need a lot of effort to be portable. In the question there is no OS and no compiler given. To find a good solution read the chapter "A Solution" in this document. There is code to cut and paste. It makes no sense to copy here. And take care about the difference of "file handle" or " FILE* stream" and "file descriptor". The first relies on the second. This is also very good described in the cited document.

