Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
getenv
◄Summary► ◄Example► ◄Up► ◄Contents► ◄Index► ◄Back►
────────────────────────────────────────────────────────────────────────────
The getenv function searches the list of environment variables for
an entry corresponding to <varname>.
Environment variables define the environment in which a process
executes. (For example, the LIB environment variable defines the
default search path for libraries to be linked with a program.)
Because the getenv function is case sensitive, the <varname>
variable should match the case of the environment variable.
Environment-table entries must not be changed directly. If an
entry must be changed, use the putenv function. To modify the
returned value without affecting the environment table, use strdup
or strcpy to make a copy of the string.
The getenv and putenv functions use the global variable environ to
access the environment table. The putenv function may change the
value of environ, thus invalidating the <envp> argument to the
main function. Therefore, it is safer to use the environ variable
to access the environment table.
Return Value
The getenv function returns a pointer to the environment-table
entry containing the current string value of <varname>. The return
value is NULL if the given variable is not currently defined.
-♦-