...
Code Block |
---|
extern char **environ; /* ... */ int main(int argc, const char *argv[], const char *envp[]) { printf("environ: %p\n", environ); printf("envp: %p\n", envp); setenv("MY_NEW_VAR", "new_value", 1); puts("--Added MY_NEW_VAR--"); printf("environ: %p\n", environ); printf("envp: %p\n", envp); } |
...
Code Block | ||
---|---|---|
| ||
int main(int argc, const char *argv[], const char *envp[]) { size_t i; setenv("MY_NEW_VAR", "new_value", 1); if (envp != NULL) { for (size_t i = 0; envp[i] != NULL; i++) { puts(envp[i]); } } return 0; } |
...
Code Block | ||
---|---|---|
| ||
extern char **environ; /* ... */ int main(int argc, const char *argv[]) { size_t i; setenv("MY_NEW_VAR", "new_value", 1); if (environ != NULL) { for (size_t i = 0; environ[i] != NULL; i++) { puts(environ[i]); } } return 0; } |
...