ENVIRONMENT settings
The Polymath
hollombe at ttidca.TTI.COM
Sat Dec 10 09:16:10 AEST 1988
In article <10551 at swan.ulowell.edu> tclark at 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 at 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
More information about the Comp.unix.questions
mailing list