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



Sokar wrote:
>
> 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();
>
> The problem is main needs parameters passed to it now. Would any1
> know what parameters I could pass to vall the main program??
>
> argv[1] is just used once as soon as main starts up and never used
> again after, so i dont mind if i loose the ability to read from it, i
> just need to be able to call main from another part of the program

Don't call main(). Instead, have main() do what it needs to do with
argc/argv, then call the recursive function, and have everything call
that instead of main().

In fact, I believe I've seen in this group that calling main() is
specifically forbidden by the standard. (Or at least it's not
standard behavior, being either "implementation defined" or
"undefined behavior".)

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:ThisIsASpamTrap@xxxxxxxxx>

.



Relevant Pages

  • Re: main(int argc, char *argv[])
    ... Sokar wrote: ... > I have my main function set up as ... > so taht i can read in a variable which is passed to the program on ... Recursively calling main is a bit funky. ...
    (comp.lang.c)
  • Re: main(int argc, char *argv[])
    ... jmccloughlin@xxxxxxxxxxx (Sokar) wrote: ... >I have my main function set up as ... >so taht i can read in a variable which is passed to the program on the ... >of them need to start jump to the start of main. ...
    (comp.lang.c)