Code Confidencebuild

Some implementation details

Here are some details about the implementation which might be interesting, although they do not affect the ISO-defined semantics of the library.

Here is a minimal eCos program which demonstrates the use of environments (see also the test case in language/c/libc/current/tests/stdlib/getenv.c):

#include <stdio.h>
#include <stdlib.h> // Main header for stdlib functions

extern char **environ; // Standard environment definition

main( int argc, char *argv[] )
 char *str;
 char *env[] = { "PATH=/usr/local/bin:/usr/bin",
 NULL };

 printf("Display the current PATH environment variable\n");

 environ = (char **)&env;

 str = getenv("PATH");

 if (str==NULL) {
  printf("The current PATH is unset\n");
 } else {
  printf("The current PATH is \"%s\"\n", str);
 return 0;