Say that I execute some command to run in the terminal within a C++ program. For instance:
int main(){
std::system("./myprog");
return 0;
}
Assume that myprog produces some output that is printed to the console. Can I make use of this output within my C++ program? For example:
int main(){
some_var = std::system("./myprog");
if (some_var == "something")
// Do something.
return 0;
}
Any help would be very much appreciated. Thanks again.
You need to use the
popenfunction: