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>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 new environment variables or modifies existing ones.
    'envstring' must be a pointer to a string with the form:

                        varname = string

    where 'varname' is the name of the environment variable to be added
    or modified, and 'string' is the variable's value (for example:
    "INCLUDE = C:\INCLUDE").  If the specified 'varname' is already set,
    its value is replaced by 'string'.  If it is not already set,
    '*envstring' is added to the environment.

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

      Notes:    Do not free a pointer to an environment variable while
                the entry is still in use, or the environment variable
                will point into freed space.  This can effectively happen
                if you pass a pointer to a local variable to putenv(),
                and then exit the function in which the local variable
                was declared.

  -------------------------------- 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