Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!columbia!rutgers!ames!sdcsvax!ucsdhub!jack!man!nu3b2!rwhite From: rwhite@nu3b2.UUCP (Robert C. White Jr.) Newsgroups: comp.lang.c Subject: Re: Accessing argc & argv from a functi Message-ID: <1130@nu3b2.UUCP> Date: Wed, 29-Jul-87 15:21:17 EDT Article-I.D.: nu3b2.1130 Posted: Wed Jul 29 15:21:17 1987 Date-Received: Fri, 31-Jul-87 06:23:46 EDT References: <420@sugar.UUCP> <39@flmis06.ATT.COM> Organization: National University, San Diego Lines: 22 Summary: Botch and kludge the runtime. In article <39@flmis06.ATT.COM>, mikel@flmis06.ATT.COM (Mikel Manitius) writes: > Well, I think we may have lost track of the initial problem. > > Sure, all of the above access the enviorment in one way or another. > > However I am still looking for a way to get at "argc" and "argv" from > a function when I don't have access to "main". getenv() and putenv() > gets it from somewhere... If you have access to the runtime stuff, you can kludge the runtime to put the argv and argc in some global variable you can find. The best solution is to have a module initalization routine [init of some sort] which the user must call from main, which will extract the array of pointers address, and store it in you own modules global space. once you use setenv, the envp argument passed to main is no longer valid. nomatter how you slice it the pointer to argv will HAVE to be passed somewhare. Robert.