I have been searching my texts, the web, and DaniWeb for information about how to share data between compiled C++ executables. I've been studying extern variables and named pipes without success. A typical program calls another program like this:
float Pi = 3.14;
system("AdjustSeaLevel.exe Pi 5.4 11.2 c f g");
and a typical receiving program looks like this:
int main(int argc, char* argv[])
{
float Pi;
// Confirm the args passed OK
for(int i=0;i<argc;i++)
cout << "Parameter argv[" << i << "] = " << argv[i] << endl;
// Then convert literals (5.4, 11.2, etc.) to floats:
float Celsius = atof(argv[2]);
float Fahrenheit = atof(argv[3]);
// Then confirm literal successfully converted to float:
Celsius = Celsius / 2; // etc.
// Or work with passed literals in other ways:
if(argv[4][0] == 'c') cout << "Calculate in Celsius! " << endl; // etc.
}
And everything works fine, but the Pi variable passed by the calling program,
float Pi = 3.14;
system("AdjustSeaLevel.exe Pi 5.4 11.2 c f g");
arrives in called prog as a literal "Pi". I don't know how to substitute
the variable into the calling program's parameters.
One way around this of course is to have the calling prog store the needed piece of data in a disk file and then have the called prog open the file and retrieve the data, which in eff lets the disk function as a "pipe." But that requires a disk read and code that I would rather avoid if possible.
If someone knows a way to do this, I would like to know. Thanks, wiglaf.