As far as I know, there's no C++ equivalent for popen() and many other C functions, and I like using C++ as much as possible... Is there any way to convert a FILE* stream to a C++ stream like std::istream so I can use things like std::getline()...?
As far as I know, there's no C++ equivalent for popen() and many other C functions, and I like using C++ as much as possible... Is there any way to convert a FILE* stream to a C++ stream like std::istream so I can use things like std::getline()...?
Behind the scenes there is probably a FILE * somewhere inside the istream. But you probably can't get to that in a public way.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Many standard libraries just wrap C I/O, but this is in no way required. And very few provide a way of getting at the FILE*.
There are some alternatives. You could write your own stream buffer to wrap FILE*s. Or you could use the (not wholly complete) Boost/GSoC2006 library Boost.Process.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
Damn... OK, I guess I'll just have to write my own getline( FILE*, std::string& ) function.