The value of an environment variable can be accessed with the getenv
function. This is declared in the header file `stdlib.h'.
getenv
(but not by any other library function). If the environment variable name is not defined, the value is a null pointer.
putenv
function adds or removes definitions from the environment. If the string is of the form `name=value', the definition is added to the environment. Otherwise, the string is interpreted as the name of an environment variable, and any definition for this variable in the environment is removed. The GNU library provides this function for compatibility with SVID; it may not be available in other systems.
You can deal directly with the underlying representation of environment objects to add more variables to the environment (for example, to communicate with another program you are about to execute; see Executing a File).
This variable is declared in the header file `unistd.h'.
If you just want to get the value of an environment variable, use getenv
.
Unix systems, and the GNU system, pass the initial value of environ
as the third argument to main
. See Program Arguments.