Hi:
int main(int argc, char *argv[]) {
if (argv[1] == "go")
method(argc, ?????);
}
/**********************/
void method(int argc, char *argv[]){
/*stuff*/
}
What should go in ????
I am trying *argv[], **argv, argv[]
none of them is working!
Hi:
int main(int argc, char *argv[]) {
if (argv[1] == "go")
method(argc, ?????);
}
/**********************/
void method(int argc, char *argv[]){
/*stuff*/
}
What should go in ????
I am trying *argv[], **argv, argv[]
none of them is working!
> if (argv[1] == "go")
This won't work. Use 'strcmp', or write your own string comparison function.
Second, why don't you just pass the string over that you want processed, where 'x' is some number:
myfunc( argc[x] );
With the prototype:
myfun( char * )
Quzah.
Hope is the first step on the road to disappointment.
For the first part, my bad!
but for the passing the array, I don't know how many arguments the user is going to enter, and I want to pass all of them.
How do you pass an unkown array to another function, like in the case above?
Thanks.
Just use the same way that 'main' uses it.
int main( int argc, char *argv[] )
Then call it the same way:
myfun( argc, argv );
Quzah.
Hope is the first step on the road to disappointment.