clearenv -- Delete Environment Variables

SYNOPSIS

 #include <env.h>

 int clearenv(void);
 

DESCRIPTION

clearenv deletes the environment-variable list for a process. Only program-scope environment variables are affected.

RETURN VALUE

clearenv returns 0 if it is successful and - 1 if it is not successful.

CAUTION

A copy of the environ pointer may not be valid after a call is made to clearenv.

EXAMPLE

The following code fragment illustrates the use of 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());
  }
  .
  .
  .
 

RELATED FUNCTIONS

getenv, setenv

SEE ALSO


Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.