Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!henry From: henry@utzoo.UUCP (Henry Spencer) Newsgroups: comp.lang.c Subject: Re: Accessing argc & argv from a functi Message-ID: <8322@utzoo.UUCP> Date: Sat, 18-Jul-87 21:27:40 EDT Article-I.D.: utzoo.8322 Posted: Sat Jul 18 21:27:40 1987 Date-Received: Sat, 18-Jul-87 21:27:40 EDT References: <22@flmis06.ATT.COM>, <102600009@datacube> Organization: U of Toronto Zoology Lines: 22 > Speaking of getenv(), if you want the definition of a single environment > variable, you can use this: > > char *path; > /* ... */ > path = getenv("PATH"); > > which searches through the string pointed to by "environ" to find something > of the form "PATH=", and returns a pointer to the char following the "=". This is not quite right. The correct form is: char *path; /* ... */ path = getenv("PATH"); if (path == NULL) [deal with the situation as appropriate] This is not just me being pedantic; all too often such checks are omitted. -- Support sustained spaceflight: fight | Henry Spencer @ U of Toronto Zoology the soi-disant "Planetary Society"! | {allegra,ihnp4,decvax,utai}!utzoo!henry