I have my array of C-Strings declared as:
char *argv[MAXARGS];
MAXARGS basically just tells us how many c strings are in the array for indexing purposes. I want to pass it to this function below...
int builtin_cmd(char **argv)
but nothing seems to go through, I called the function like this.
char *argv[MAXARGS];
builtin_cmd(argv);
but once i get into the function builtin_cmd
and try to print using
printf("%s\n", argv[0]);
it prints nothing.... but when i do this before calling the function...
char *argv[MAXARGS];
printf("%s\n", argv[0]);
//builtin_cmd(argv);
it will print the first C string in the array of c strings just fine. My thoughts are that I am passing the structure incorrecly and I would like to know the correct way to pass it to the function.
EDIT:
int builtin_cmd(char **argv);
int main()
{
char *argv[128];
//put 'quit' into argv[0]..
printf("%s\n", argv[0]); //prints 'quit'
builtin_cmd(argv);
}
int builtin_cmd(char **argv)
{
printf("%s\n", argv[0]); //prints nothing
}
The problem is, again, that I cant seem to get argv into the function. It also compiles with no errors or warnings.