In article <8cc422cd-9744-4d24-ae2b-06f6a8079396@
56g2000hsm.googlegroups.com>,
says...
[ ... ]
> thanks for the fast reply. I forgot to mention that our code is
> running under Linux. I've already found popen() and pclose() looking
> on google, but I'd have preferred to have the output of popen() into a
> stream object instead of a FILE.
>
> Anyway, I think I will try with this solution. Thanks again,
You might also want to look through your compiler's documentation. Quite
a few include a ctor to create a stream object from a UNIX file
descriptor (and you can use fileno() to get a UNIX file descriptor from
a FILE *). Assuming you have such a ctor available, it should be pretty
easy to write a function that calls popen and returns a reference to a
stream instead of a FILE *.
If you don't have that avaiable, the job will be a little more work, but
not tremendously so -- you'll need to create your own streambuf that
handles underflow by reading from the pipe, and then create a stream
that uses that streambuf. If you do some searching, you can probably
find a number of posts from James Kanze on similar subjects.
--
Later,
Jerry.
The universe is a figment of its own imagination.