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



(supersedes <mn.f3d17d544d971c16.15512@xxxxxxxxxxxxxx>)

Sokar wrote on 29/04/05 :
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

Thanks and regards

Why in the world do you have to call main() ? While it is technically possible in C (but not in C++, for good reasons, I guess), it exposes a design error. There are enough code structure in C to avoid that.


- functions
- while
- do-while
- for

Write a better algorithm and stop writing spaghetti code, please...

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

"C is a sharp tool"

.



Relevant Pages

  • Re: Internet Mail registry error
    ... The bad file name indicates taht the command was not properly entered. ... There must be one or more spaces after the regsvr32 and before the outlmime.dll. ... You can also get to the Internet Explorer newsgroups via this web site: ...
    (microsoft.public.internet.mail)
  • ld.so.1 removed
    ... is taht I could'nt excute any command. ... How can I manage to resolve ...
    (SunManagers)
  • Re: Is there a way to "print" a list of the songs on file?
    ... Dr. Jose M. Paliza wrote: ... > I do taht? ... Get a directory listing and print that e.g. from command line: ...
    (microsoft.public.windowsmedia.player)