ENVIRONMENT settings

Doug Gwyn gwyn at smoke.BRL.MIL
Fri Dec 9 17:40:41 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?

	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 */



More information about the Comp.unix.questions mailing list