...
Code Block |
---|
extern char **environ;
/* ... */
int main(int argc, char *argv[], 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 | ||
---|---|---|
| ||
extern char **environ;
/* ... */
int main(int argc, char *argv[]) {
setenv("MY_NEW_VAR", "new_value", 1);
if (environ != NULL) {
for (size_t i = 0; environ[i] != NULL; i++) {
puts(environ[i]);
}
}
return 0;
}
|
...
Code Block |
---|
extern char **environ; #define envp environ /* ... */ main(int argc, char *argv[]) |
...