fstream -> FILE*

B

barcaroller

Is it possible to somehow get a FILE* file pointer from an fstream object?
The reason I'm asking is that I have C++ code that now needs to link to a C
library which requires FILE* file pointers.
 
Z

Zjargands

barcaroller said:
Is it possible to somehow get a FILE* file pointer from an fstream object?
The reason I'm asking is that I have C++ code that now needs to link to a C
library which requires FILE* file pointers.

I don't believe you can. As a class, fstream has no reason to use a
FILE* internally, it can use whatever it wants. It should be trivial to
extract the open file name however, and then reopen the file using the c
library. Make suer you set your put and get pointers for the file to the
same place they are in the fstream.



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkkw6HEACgkQlsOBXZ7DoXYmvACdFmO0sO/nKScdZ20eE1HRM04s
KBEAoIm2Rt5NUcJFEWHR57avE7ey2fLJ
=v+/o
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top