Running an executable with parameters in C++ and get the return value;

c++, executable, parameters, return-value

Solution

Portable way:

 int retCode = system("prog.exe arg1 arg2 arg3");

With embedded quotes/spaces:

 int retCode = system("prog.exe \"arg 1\" arg2 arg3");

Problem

How do you run an executable with parameters passed on it from a C++ program and how do you get the return value from it? Something like this: c:\myprogram.exe -v

Original source

Related problems