a pointer about *argv[]
I'm assuming that the reason for passing &argc
and &argv
in the first place is so that you can update them inside init_arg
. Here's how I prefer to write such functions, in general:
/* * init_arg: do something useful with argc and argv, and update argc and argv * before returning so that the caller can do something else useful that's * not shared with all the other callers of init_arg(). * (this comment of course needs updating to describe the useful things) */void init_arg(int *argc0, char ***argv0) { int argc = *argc0; char **argv = *argv0; ... all the operative code goes here, and then ... *argc0 = argc; *argv0 = argv;}
Of course this means you must not do early return
s inside init_arg
, so there are some tradeoffs, but it sure is a lot easier to work with the same regular old argc
and argv
inside init_arg
.