Okay, let's say that I have b.exe, which takes a string argument. I want to invoke b.exe within a.cpp, with system:
string s1 = "hallo";
system("b.exe s1");
printf("s1 after invoke = %s",s1);
and this is the code in b.cpp:
int main(string s)
{
s = "hello world";
return 0;
}
what I want is, when I run a.exe, the output will be:
s1 after invoke = hello world
is it possible to do that? basically, i just want to pass a variable to an exe, but it must be by reference, not only by value because I want that variable to be processed and modified within the exe that I invoked. I've already searched the solution on the internet, but it only provides me tha way to pass a variable by value to the exe, not by reference..
any suggestion will be very appreciated, but if possible, I want the suggestion in the form of the above correction code and include files, if any. thanks for your help :)
Open a command prompt (Windows+R, type "cmd" and hit enter). Then change to the directory housing your executable ("cd enter-your-directory-here"), and run the command with the parameters.
For example, entering C:\abc.exe /W /F on a command line would run a program called abc.exe and pass two command line arguments to it: /W and /F.
Batch parameters (Command line parameters): In the batch script, you can get the value of any argument using a % followed by its numerical position on the command line. The first item passed is always %1 the second item is always %2 and so on. If you require all arguments, then you can simply use %* in a batch script.
It can be solved with reading from a temporary file a remarked version of the parameter. @echo off SETLOCAL DisableDelayedExpansion SETLOCAL for %%a in (1) do ( set "prompt=" echo on for %%b in (1) do rem * #%1# @echo off ) > param. txt ENDLOCAL for /F "delims=" %%L in (param.
It is not possible to modify command line arguments among different processes. s1
is known only to A.CPP, and s
is only known to B.CPP.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With