Listing 1

#include <stdio.h>

main(int argc, char *argv[], char *envp[])
{
  int i = 0;

  while (envp[i] != NULL) {
     printf("envp[%d] ==> |%s|\n", i, envp[i]);
     ++i;
  }
  printf("\nenvironment variable count = %d\n", i);
}



                 Output

envp[0]  ==>  |COMSPEC=C:\COMMAND.COM|
envp[1]  ==>  |PROMPT=$p $g|
envp[2]  ==>  |PATH=c:\dos;c:\util;|
envp[3]  ==>  |ABC=def|

environment variable count = 4