C language > Expert questions

environ

(1/1)

czerny:
I need access to the program environment (not with getenv() etc., but the adress)
The following crashes:
---------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>

int main(int argc, const char *argv[], const char *envp[]) {
   size_t i;
   if (envp != NULL) {
      for (i = 0; envp != NULL; i++) {
         puts(envp);
      }
   }
   return 0;
}
-----------------------------------------------------------

Is there a variable like 'environ' pointing to the global environment?

czerny

czerny:
Under POSIX I think the following is defined:

extern char **environ;

Under Pelles C there is nothing with this name. Is there something equivalent?

czerny

AlexN:
Look at this:

http://www.codersource.net/win32_getenvironmentvariable.html

Alex ;-)

Navigation

[0] Message Index

Go to full version