### getenv -- Search for Environment Variables

Format

>     #include <stdlib.h>
>     char *getenv(const char *varname);

Language Level: ANSI, POSIX, XPG4
getenv searches the list of environment variables for an entry corresponding to varname.

Return Value
getenv 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 or if the system does not support environment variables.

You should copy the string that is returned because it may be written over by a subsequent call to putenv.

Example
In this example, pathvar points to the value of the PATH environment variable.

    #include <stdio.h>
    #include <stdlib.h>

    int main(void)
    {
       char *pathvar;
       pathvar = getenv("PATH");
       if (NULL == pathvar)
            printf("Environment variable PATH is not defined./n");
       else
            printf("Path set by environment variable is successfully stored.\n");
       return 0;

       /************************************************************************
          The output should be:

          Path set by environment variable PATH is successfully stored.
       ************************************************************************/
    }

putenv -- Modify Environment Variables
<stdlib.h>