Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C - <b>getenv() get a value from the environment table</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
getenv()                 Get a Value from the Environment Table

 #include   <stdlib.h>

 char       *getenv(varname);
 char       *varname;                    Name of environment variable

    getenv() searches the list of environment variables for an entry
    corresponding to 'varname'.

    Returns:    A pointer to the environment table containing the current
                string value of 'varname'.  NULL is returned if 'varname'
                is not currently defined.

      Notes:    Entries can be changed using putenv().  Use strdup() or
                strcpy() to modify the returned value without affecting
                the environment table.

  -------------------------------- Example ---------------------------------

    The following statements get some environment settings and print them
    out.

            #include <stdlib.h>
            char *pathvar, *libvar;

            main()
            {
                pathvar = getenv("PATH"); /* NULL if no PATH */
                libvar = getenv("LIB");   /* NULL if no LIB setting */
                printf("PATH AND LIB ENVIRONMENT SETTINGS\n");
                printf("\tPATH: %s\n",pathvar);
                printf("\tINCLUDE: %s\n",inclvar);
            }

See Also: putenv() strdup() strcpy()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson