a pointer about *argv[]
arguments, c, gdb, pointers, program-entry-point
Solution
You need to add a pair of parentheses around (*argv) to change the order of evaluation. The way you currently have it, the [1] is evaluated first, yielding an invalid pointer, which then gets dereferenced, causing undefined behavior.
printf("%s\n", (*argv)[1]);
Problem
This is my `main.c` ``` ...... int main(int argc, char **argv) { init_arg(&argc, &argv); ...... } ``` This is my `init_arg.c` ``` ...... void init_arg(int *argc, char ***argv) { printf("%s\n", *argv[1]); ...... } ``` I compiler it with no error and warning. I run it: `./a.out include` It get Segmentation fault When I debug it, I found step `printf("%s\n", *argv[1]);` get wrong, It show: `print *argv[1]` `Cannot access memory at address 0x300402bfd` I want to know, How to print `argv[1]` in `init_arg()` function.