ENVIRONMENT settings

Guy Harris guy at auspex.UUCP
Sat Dec 10 14:40:19 AEST 1988


>here's a portion of the code pulled out from a source file
>
>main (argc, argv, envp)
...
>     char **envp;
>{
>	/* do something */
> 	for (; *envp; envp++) {
>	printf("%s\n", *envp);
	...

You pulled it from the wrong source file; this may be something like
the "printenv" or "env" commands.  If you want to dump the entire
environment, you have to do something like that; however, if you just
want to look at some *particular* environment variable, it's easier (and
quite possibly more portable) to just do something like

	char *p;
	extern char *getenv();

	p = getenv("LOGNAME");

which will get the value of the environment variable "LOGNAME".



More information about the Comp.unix.questions mailing list