Hello!
Imagine I want to have my program run a shell script and I want to use its return in my program. Could you please tell me how to read it back into my program?
Thank you!
Also, best practices suggestions are welcome.
I tried this, but the program expects an user input, as you can imagine. (And I think it is because the shell script has already been piped to stdout by the time I am expecting to retrive it, right?)
Code:#include <cstdlib> #include <iostream> int main() { system("cd ~; ls | wc -l"); int wc; std::cin >> wc; std::cout << "Wc is " << wc; return 0; }