Convert from FILE to fstream and vice versus

Dear everyone,

I am writing a C++ program and using fstream(ifstream and ofstream). Additionally, I am using a C open source library and its methods requires "FILE*" inputs. Therefore, I would like to ask whether there is any way to convert between FILE and fstream? I searched in the forum but there was no answer. I did google and someone said that we can convert FILE <-> file handle <-> fstream
 
http://www.flounder.com/handles.htm 


I tried but it didn't work. For example, they said that in order to convert from FILE * to C Library handle, using this method
 
http://www.flounder.com/handles.htm#FILE%20*%20to%20C%20Library%20handle 


1
2
<stdio.h>
int _fileno(FILE * f)


I wrote a simple test
1
2
3
        FILE * inFile;
        inFile = fopen("temp.xml", "r");
        int handle=_fileno(inFile);


However, GCC told me that "‘_fileno’ was not declared in this scope". What is wrong?

Or is there other way to do the conversion.

Thank you for your time and consideration



_fileno() appears to be a Windows function.
Thanks helios.

If so, is there any similar function in Linux? Or is there any way to convert FILE to fstream?
Topic archived. No new replies allowed.