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.

See:
http://www.cplusplus.com/reference/clibrary/cstdlib/system/

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.