M
mwebel
Hi,
is is also a C question but the program im writing is in C++ and it
applies as well so:
i have a program in the "main(int argc, const char ** argv)"
and i want to make a library. for example "myFunc(int argc, const char
** argv)"
i already know what the parameters mean (argc number of params and argv
params field)
The problem is:
Could somebody explain me how to fake a command line?
i'd like for example to be able to pass the parameters:
-x myfile
-f flag1
to the programm.
the commandline would seem like:
"foo.exe -x myfile -f flag1"
but how do i exactly put this together? the params are originally
stored in c++ strings. Thats not the problem since a c++ string can
fake c strings.
my main problem is how to define the argv since its a pointer to a
pointer.
do i have to terminate it? how do i define it? im not that c
experienced.
can i say:
char *ptest[5];
ptest[0]="foo.exe";
ptest[1]="-x";
ptest[2]="myfile";
ptest[3]="-f";
ptest[4]="myflag";
char **pptest=ptest;
myFunc(5,ptest);
?
thanks for any help!
is is also a C question but the program im writing is in C++ and it
applies as well so:
i have a program in the "main(int argc, const char ** argv)"
and i want to make a library. for example "myFunc(int argc, const char
** argv)"
i already know what the parameters mean (argc number of params and argv
params field)
The problem is:
Could somebody explain me how to fake a command line?
i'd like for example to be able to pass the parameters:
-x myfile
-f flag1
to the programm.
the commandline would seem like:
"foo.exe -x myfile -f flag1"
but how do i exactly put this together? the params are originally
stored in c++ strings. Thats not the problem since a c++ string can
fake c strings.
my main problem is how to define the argv since its a pointer to a
pointer.
do i have to terminate it? how do i define it? im not that c
experienced.
can i say:
char *ptest[5];
ptest[0]="foo.exe";
ptest[1]="-x";
ptest[2]="myfile";
ptest[3]="-f";
ptest[4]="myflag";
char **pptest=ptest;
myFunc(5,ptest);
?
thanks for any help!