Path: utzoo!utgpu!watmath!clyde!att!rutgers!mailrus!ames!haven!adm!smoke!gwyn
From: gwyn@smoke.BRL.MIL (Doug Gwyn )
Newsgroups: comp.unix.questions
Subject: Re: ENVIRONMENT settings
Message-ID: <9117@smoke.BRL.MIL>
Date: 9 Dec 88 07:40:41 GMT
References: <10551@swan.ulowell.edu>
Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) )
Organization: Ballistic Research Lab (BRL), APG, MD.
Lines: 13

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?

	extern char *getenv();	/* in standard C library */
	char *logname;
	...
	if ( (logname = getenv( "LOGNAME" )) == 0 )
		logname = "nobody";	/* use default if not set */
	...
	printf( "Your LOGNAME is \"%s\"\n", logname );	/* for example */