#include #include static void run_getenv (const char * name) { char * value; value = getenv (name); if (! value) { printf ("'%s' is not set.\n", name); } else { printf ("%s = %s\n", name, value); } } int main () { char * name = "moo"; /* Variable is not set. */ run_getenv (name); /* Write into empty variable. */ setenv ("moo", "chops", 0); run_getenv (name); /* This doesn't change the value because "overwrite" is 0. */ setenv ("moo", "drops", 0); run_getenv (name); /* This changes the value because "overwrite" is 1. */ setenv ("moo", "drops", 1); run_getenv (name); return 0; }