GETENVSection: Linux Programmer's Manual (3)
Index Return to Main Contents
NAMEgetenv - get an environment variable
#include <stdlib.h> char *getenv(const char *name);
DESCRIPTIONThe getenv() function searches the environment list to find the environment variable name, and returns a pointer to the corresponding value string.
RETURN VALUEThe getenv() function returns a pointer to the value in the environment, or NULL if there is no match.
CONFORMING TOSVr4, POSIX.1-2001, 4.3BSD, C89, C99.
NOTESThe strings in the environment list are of the form name=value.
As typically implemented, getenv() returns a pointer to a string within the environment list. The caller must take care not to modify this string, since that would change the environment of the process.
The implementation of getenv() is not required to be reentrant. The string pointed to by the return value of getenv() may be statically allocated, and can be modified by a subsequent call to getenv(), putenv(3), setenv(3), or unsetenv(3).
SEE ALSOclearenv(3), putenv(3), setenv(3), unsetenv(3), environ(7)
COLOPHONThis page is part of release 3.21 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/.