Re: main(int argc, char *argv[])



Michael Mair wrote:
> David Resnick wrote:
> > Recursively calling main is a bit funky. Why not have main call
some
> > other
> > function (which takes no arguments) which is then used for the
> > recursion?
> >
> > Anyway, you could always call main later with main(0,NULL).
> > Or if you want, you could squirrel away (in a static) the original
> > argc and argv and reinvoke main with them later.
>
> Not exactly. argv[argc] must be NULL, i.e. you need
> main(0, p), where *p==NULL.
>
> Cheers
> Michael
> --
> E-Mail: Mine is an /at/ gmx /dot/ de address.

Um, why? I agree with what you say when main is originally invoked by
the implementation. If invoked recursively and one no longer cares
about using argc or argv why is main(0,NULL) not acceptable? In fact,
if one is recursively invoking main (probably a bad idea), having argv
be NULL seems
like one reasonable way to indicate this is not the original
invocation.

-David

.



Relevant Pages

  • Re: modifying the strings pointed to by argv
    ... The standard just says "argc and argv and the strings pointed to ... by the argv array shall be modi�able by the program." ... functions or for the recursion of main. ...
    (comp.lang.c)
  • Re: main(int argc, char *argv[])
    ... function which is then used for the recursion? ... about using argc or argv why is mainnot acceptable? ... The small amount of justification came from a code length limit ...
    (comp.lang.c)