Format
#include <stdlib.h> char *getenv(const char *varname);
Language Level: ANSI
Threadsafe: Yes.
Description
The getenv() function searches the list of environment variables for an entry corresponding to varname.
Return Value
The getenv() function returns a pointer to the string containing the value for the specified varname in the current environment. If getenv() cannot find the environment string, NULL is returned, and errno is set to indicate the error.
Example that uses getenv()
#include <stdlib.h> #include <stdio.h> /* Where the environment variable 'PATH' is set to a value. */ int main(void) { char *pathvar; pathvar = getenv("PATH"); printf("pathvar=%s",pathvar); }
Related Information
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.