Chapter Contents

Previous

Next
clearenv

clearenv



Delete Environment Variables

Portability: POSIX.1 conforming


SYNOPSIS
DESCRIPTION
RETURN VALUE
CAUTION
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


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 variables\n", count_env());

if (clearenv() !=0)
   perror("clearenv() error");
else {
   printf("Now there are %d environment variables\n", count_env());
}
.
.
.


RELATED FUNCTIONS

getenv , setenv


SEE ALSO


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.