Re: main(int argc, char *argv[])
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Fri, 29 Apr 2005 19:52:00 GMT
jmccloughlin@xxxxxxxxxxx (Sokar) writes:
> I have my main function set up as
>
> int main(int argv, char *argv[])
>
> so taht i can read in a variable which is passed to the program on the
> command line. The problem is that main calls other functions and some
> of them need to start jump to the start of main. If my main setup was
> just int main() this would be no problem, i could just call main();
As others have mentioned, if you really want recursion it's best to
have a separate recursive function that you call from main. It's
legal to call main recursively, but the new invocation will (probably)
have no way of knowing that it's not the original one, so it will try
to process the command-line arguments all over again. (You can pass
in extra information in the parameters, or you can use a static
variable, but both approaches are kludges.)
But since you said you need to "jump to the start of main", I suspect
what you really need is not recursion but simply a loop. Recursion is
a powerful tool, but you shouldn't use it unless it's appropriate.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.
- References:
- main(int argc, char *argv[])
- From: Sokar
- main(int argc, char *argv[])
- Prev by Date: Re: How is strlen implemented?
- Next by Date: Re: How is strlen implemented?
- Previous by thread: Re: main(int argc, char *argv[])
- Next by thread: Re: main(int argc, char *argv[])
- Index(es):
Relevant Pages
|