FILE* and fstream

R

Ralf Goertz

Hi,

is there a way to use a FILE* variable to create a filestream? The
reason I ask is that I need to use a pipe via popen() and want it to be
a stream. Alternatively, I could use a generic c++ version of popen()
but I haven't found one.

Thanks,

Ralf
 
V

Victor Bazarov

Ralf said:
is there a way to use a FILE* variable to create a filestream?

Not portably, no. If your implementation actually has it, there might
be a way, but then it would be implemenation-specific. You'd need to
ask in the newsgroup dedicated to your compiler.
The
reason I ask is that I need to use a pipe via popen() and want it to
be a stream. Alternatively, I could use a generic c++ version of
popen() but I haven't found one.

There isn't a generic 'popen'. It's not a standard function.

V
 
R

Ralf Goertz

Victor said:
Not portably, no. If your implementation actually has it, there might
be a way, but then it would be implemenation-specific. You'd need to
ask in the newsgroup dedicated to your compiler.

Thanks, and what about file descriptors? So far I use the evil tempnam()
function since the preferred mkstemp provides a file descriptor. Can
that be used to create a stream?

Ralf
 
V

Victor Bazarov

Ralf said:
Thanks, and what about file descriptors? So far I use the evil
tempnam() function since the preferred mkstemp provides a file
descriptor. Can that be used to create a stream?

I don't know what you're talking about. :)

No, there is no such thing as "file descriptor" in C++.

V
 
L

loufoque

Ralf Goertz wrote :
is there a way to use a FILE* variable to create a filestream? The
reason I ask is that I need to use a pipe via popen() and want it to be
a stream. Alternatively, I could use a generic c++ version of popen()
but I haven't found one.

Some implementations have overloads of the constructors and open
functions that take a FILE* or a fd, and also a fd() member function
that returns the fd.

See the documentation of your implementation.
 
E

Eric Pruneau

Victor Bazarov said:
I don't know what you're talking about. :)

No, there is no such thing as "file descriptor" in C++.

V

FileStream is actually Microsoft .net framework specific...
you should ask in a microsoft group

eric
 

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

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top