/*********************************************************** * * environment.c * * 4/15/02 Jeff Ondich * Last modified 4/18/08 * * Illustrates the seldom-used third parameter to main(), * by printing out the list of environment variables. * * Also demonstrates the getenv() function by printing * the HOME environment variable and trying to print * the MOOSE environment variable. * **********************************************************/ #include #include #include int main( int argc, char *argv[], char *envp[] ) { char *p; int i; for( i=0; envp[i] != NULL; i++ ) { printf( "%s\n", envp[i] ); } printf( "\n\n" ); p = getenv( "HOME" ); if( p == NULL ) printf( "HOME is not defined\n" ); else printf( "HOME = %s\n", p ); p = getenv( "MOOSE" ); if( p == NULL ) printf( "MOOSE is not defined\n" ); else printf( "MOOSE = %s\n", p ); return 0; }