http://pstreams.sourceforge.net/
pstreams is apparently a very simple library, reimplementation of popen () for C ++.
The library is very easy to install, consisting of only one header file. You can download the header file here and add it to your application:
http://pstreams.cvs.sourceforge.net/viewvc/pstreams/pstreams/pstream.h?view=log
I thought I would rather simply: send a command to the system and get its output. The pstreams homepage (above) and the documentation offer the following example:
redi::ipstream in("ls ./*.h");
std::string str;
while (in >> str) {
std::cout << str << std::endl;
}
This seems to work well, but the code actually covers all the spaces and carriage returns from the output. Try the following:
redi::ipstream in("ls -l");
std::string str;
while (in >> str) {
std::cout << str
}
std::cout << std::endl;
and we get a concatenated looong string with no space.
, , :
redi::ipstream in("ls -l");
std::string str;
while (!in.rdbuf()->exited()) {
in >> str;
}
std::cout << str << std::endl;
.
.
:
++
++ POSIX?
: pstreams, - .