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 6.0 - <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);
 const char *varname;                    Name of environment variable

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

    Returns:    A pointer to the environment table indicating the entry
                that contains the current string value of 'varname'.  If
                'varname' is not currently defined, NULL is returned.

      Notes:    Entries can be changed with 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