putenv
Purpose
Alters an environment.
Syntax
int putenv (str)
char *str
Description
The putenv routine alters the value of an environment
variable by altering an existing variable or by creating
a new one. The str points to a string of the form
name=value where name is the environment variable, and
value is the new environment variable value. The string
pointed to by str becomes part of the environment. After
putenv is called, environmental variables are not in
alphabetical order. The space used by str is no longer
used once a new string-defining name is passed to putenv.
The putenv routine uses malloc to enlarge the environ-
ment.
Note: The putenv routine manipulates the environment
pointed to by environ and can be used in conjunction with
getenv. However, the envp (third) parameter to main is
not changed. Warning: Calling putenv with an automatic
variable as a parameter, then exiting the calling func-
tion while str is still part of the environment, causes
unpredictable results.
Related Information
"exec: execl, execv, execle, execve, execlp, execvp,"
"getenv, NLgetenv," "malloc, free, realloc, calloc" and
"environment."
"Overview of International Character Support" in Managing
the AIX Operating System.