Wrapping a commandline program with pstream
I want to be able to read and write to a program from C++. It seems like pstream can do the job, but I find the documentation difficult to understand and have not yet find an example. I have setup the following minimum working example. This opens python, which in turn (1) prints hello (2) ask input, and (3) prints hello2 : #include <iostream> #include <cstdio> #include "pstream.h" using namespace std; int main(){ std::cout << "start"; redi::pstream proc(R"(python -c "if 1: print 'hello' raw_input() print 'hello2' ")"); std::string line; //std::cout.flush(); while (std::getline(proc.out(), line