Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: let there be const

...

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
bgColor#ffcccc
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
bgColor#ccccff
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;
}

...