c pass variable as parameters to an exe

October 29, 2010 at 08:05:25
Specs: Windows XP, 4gb
Hi! How do you pass variables as parameters to an executable in c?

example: int x=123, y=321;
system("some_program.exe x y");

this code just passed x as in the letter x and not the 123.

I would like my c program to pass the value of the variable, and not the variable name.

See More: c pass variable as parameters to an exe

Report •

October 29, 2010 at 08:38:03
For C? Build a string using vsprintf(), then pass that string to system().

How To Ask Questions The Smart Way

Report •

October 30, 2010 at 08:18:10
Hi! Thanks but I already figured it out. :

char p1[100]="param1 ", p2[256]="param2", call_bat[256]="receive_two_parameters.bat ";

strcat(call_bat, p1);
strcat(call_bat, p2);


Report •

Related Solutions

Ask Question