Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!decwrl!pyramid!prls!philabs!ttidca!hollombe From: hollombe@ttidca.TTI.COM (The Polymath) Newsgroups: comp.unix.questions Subject: Re: ENVIRONMENT settings Message-ID: <3541@ttidca.TTI.COM> Date: 9 Dec 88 23:16:10 GMT References: <10551@swan.ulowell.edu> Reply-To: hollombe@ttidcb.tti.com (The Polymath) Organization: The Cat Factory Lines: 31 In article <10551@swan.ulowell.edu> tclark@hawk.ulowell.edu (T.C. Clark) writes: }I'm writing a C program in which I would like to read in }some of the user's ENVIRONMENT settings (ie. logname, printer) }Can someone give me an idea on how to read these in and use }them? Nothing to it. Code your main() as follows: main (argc, argv, envp) int argc; char *argv[]; char *envp[]; { /* etc. */ } envp stands for ENVironment Pointers. It's a null terminated array of pointers to null terminated strings in the format name=value, where name is the name of the environment variable and value is what it's set to. It will contain all the user's currently set environment variables. Alternatively, you can use the getenv(3) function if you only want to access some specific environment variables. As usual, RTFM. (-: -- The Polymath (aka: Jerry Hollombe, hollombe@ttidca.tti.com) Illegitimati Nil Citicorp(+)TTI Carborundum 3100 Ocean Park Blvd. (213) 452-9191, x2483 Santa Monica, CA 90405 {csun|philabs|psivax}!ttidca!hollombe