#include <env.h> int clearenv(void);
clearenv
deletes the environment-variable list for a process. Only
program-scope environment variables are affected.
clearenv
returns 0 if it is successful and - 1 if it
is not successful.
environ
pointer may not be valid after a call is
made to clearenv
.
clearenv
:
/* This example requires compilation with the posix option */ /* to execute successfully. */ #include <stdlib.h> #include <stdio.h> extern char **environ; int count_env() { int num; for (num=0; environ[num] !=NULL; num++); return num; } . . . printf("There are %d environment variablesn", count_env()); if (clearenv() !=0) perror("clearenv() error"); else { printf("Now there are %d environment variablesn", count_env()); } . . .
getenv
, setenv
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.