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>putenv() create new environment variables</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 putenv()                Create New Environment Variables

 #include   <stdlib.h>                   Required for declarations only

 int        putenv(envstring);
 char       *envstring;                  Environment string definition

    putenv() adds or modifies environment variables. 'envstring' must be
    a pointer to a string in the form:

                         varname = string

    where 'varname' identifies the environment variable to be added or
    modified and 'string' identifies the value of the variable (for
    example: INCLUDE = C:\INCLUDE).  'string' replaces an existing value
    if 'varname' is already set.  Otherwise, 'envstring' is added to the
    environment.

    Returns:    Zero, if successful.  -1 is returned if an error occurs.

      Notes:    If a pointer to an environment variable is freed while
                the entry is still in use, the environment variable will
                point to freed space.  This can effectively happen if a
                pointer to a local variable is passed to putenv(), and
                the function in which the local variable was declared is
                exited.

 Portability:   Not supported by ANSI standard.

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

    The following statements change the PATH to C:\WORK, and then print
    an appropriate message.

           #include <stdlib.h>
           int result;

           main()
           {
               if ((result = putenv("PATH = C:\WORK")) == 0)
                   printf("path changed to C:\\WORK");
           }


See Also: getenv()

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