Hey guys , i written a code to call another external program i wrote , but the problem i am having is i am unable to save the output into a variable.

using namespace std;

int main()

const char r = system("samp -s1122") ;
 cout << r << endl;

The variable r should be holding the result of the external program , but it is not displaying anything. Would like some help in this area. thanks.


The function returns an int that is "system-dependent" (could be an exit code for the program, could be garbage).

Perhaps write the output of the program to a textfile (using "samp -s1122 > text.out") and read that into your program.
I'm not sure if this is a case where you could use piping as that's beyond me.