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



Michael Mair wrote:
> David Resnick wrote:
>
.... snip ...
>>
>> 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.

No, they will be so on the initial call of main. Once that happens
what you do next is up to you. For example, argc will hold a
positive value on the initial call. You could use that to detect a
recursive call by passing a negative argument. It all sounds
highly purposeless though.

Stoopid program, should run and terminate:

int main(int a, char **v)
{
if (a > 0) main(-5, 0); /* do 1st recursion */
else if (a < 0) ( /* in recursive call */
/* make it known if you wish */
main(a+1, 0);
}
return 0;
}

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson


.