getenv() General Function getenv() Read environmental variable char *getenv(VARIABLE) char *VARIABLE; A program may read variables from its environment. This allows the program to accept information that is specific to it. The environment consists of an array of strings, each having the form VARIABLE=VALUE. When called with the string VARIABLE, getenv reads the environment, and returns a pointer to the string VALUE. ***** Example ***** This example prints the environmental variable PATH. #include <stdio.h> main() { char *env; extern char *getenv(); if ((env = getenv("PATH")) == NULL) { printf("Sorry, cannot find PATH\n"); exit(1); } printf("PATH = %s\n", env); } ***** See Also ***** environmental variables, envp, exec, sh ***** Diagnostics ***** When VARIABLE is not found or has no value, getenv returns NULL. COHERENT Lexicon Page 1