fstream -> FILE*

Discussion in 'C++' started by barcaroller, Nov 29, 2008.

  1. barcaroller

    barcaroller Guest

    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.
    barcaroller, Nov 29, 2008
    #1
    1. Advertising

  2. barcaroller

    Zjargands Guest

    barcaroller wrote:
    > 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-----
    Zjargands, Nov 29, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave

    fstream file i/o

    Dave, Aug 4, 2003, in forum: C++
    Replies:
    2
    Views:
    368
    Mike Wahler
    Aug 4, 2003
  2. Brandon McCombs
    Replies:
    8
    Views:
    480
    Dave O'Hearn
    Nov 24, 2003
  3. Sanyi Benczik

    File associated with fstream object?

    Sanyi Benczik, Jan 20, 2004, in forum: C++
    Replies:
    2
    Views:
    417
    Dietmar Kuehl
    Jan 21, 2004
  4. Armando
    Replies:
    6
    Views:
    745
    Armando
    Jan 29, 2004
  5. roughtrader
    Replies:
    3
    Views:
    438
    James Kanze
    Feb 17, 2009
Loading...

Share This Page