Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. C++ IO Library

C++ IO Library

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Justin Turney
    wrote on last edited by
    #1

    I am using a C library which contains functions that use FILE* to send data to a file. Since I am writing my code in C++ and using ofstream, is there a way to gain access to the underlying FILE variable that is nested in ofstream to send to these functions? Any help will be gladly accepted. Justin Turney

    V A M 3 Replies Last reply
    0
    • J Justin Turney

      I am using a C library which contains functions that use FILE* to send data to a file. Since I am writing my code in C++ and using ofstream, is there a way to gain access to the underlying FILE variable that is nested in ofstream to send to these functions? Any help will be gladly accepted. Justin Turney

      V Offline
      V Offline
      valikac
      wrote on last edited by
      #2

      I am not familiar with C and FILE *. However, ofstream does have a function that returns a pointer to the data buffer. rdbuf() Kuphryn

      1 Reply Last reply
      0
      • J Justin Turney

        I am using a C library which contains functions that use FILE* to send data to a file. Since I am writing my code in C++ and using ofstream, is there a way to gain access to the underlying FILE variable that is nested in ofstream to send to these functions? Any help will be gladly accepted. Justin Turney

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        I do believe it is in stdio.h

        1 Reply Last reply
        0
        • J Justin Turney

          I am using a C library which contains functions that use FILE* to send data to a file. Since I am writing my code in C++ and using ofstream, is there a way to gain access to the underlying FILE variable that is nested in ofstream to send to these functions? Any help will be gladly accepted. Justin Turney

          M Offline
          M Offline
          Mike Nordell
          wrote on last edited by
          #4

          Justin Turney wrote: is there a way to gain access to the underlying FILE variable that is nested in ofstream No, at least not in a portable way. You might cheat by hard-coding for a particular implementors specific version of the C++ library, but since that's a really ugly thing to do I obviously can do nothing but strongly recommend against it. Now, what you can do is drop the f requirement and use ostream. Then you could instantiate a basic_ostream class that is implemented with a specialized streambuf that both uses and exposes the C stream interface (using FILE*). Since this is almost a FAQ, I refer you to google and/or comp.lang.c++.moderated for further information.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups