Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // Created by lhk on 21.08.16.
- //
- #include "urho_popen.h"
- void get_pT_urho_popen(const double& u, const double& rho, double& p, double& T){
- FILE *in;
- char buff[512];
- //const char* command=("Python/python3 piap.py "+ to_string(u)+" "+to_string(rho)).c_str();
- //cout<< "command for subprocess: "<<command<<endl;
- ostringstream command;
- command<<"cd ; python3 piap.py "<<u<<" "<<rho;
- cout<<"command for subprocess: "<<command.str()<<endl;
- if(!(in = popen(command.str().c_str(), "r"))){
- cout<<"some problem with the subprocess"<<endl;
- }
- double data[2];
- int idx=0;
- cout<<"ran the subprocess"<<endl;
- while(fgets(buff, sizeof(buff), in)!=NULL){
- data[idx] = atof(buff);
- cout <<data[idx]<<endl;
- idx++;
- cout <<"new line"<<endl;
- }
- pclose(in);
- p=data[0];
- T=data[1];
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement