Skip to content

Instantly share code, notes, and snippets.

@dstein64
Last active October 24, 2017 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dstein64/86d7d6444e80d150a5f826e809ba7384 to your computer and use it in GitHub Desktop.
Save dstein64/86d7d6444e80d150a5f826e809ba7384 to your computer and use it in GitHub Desktop.
/*** printenv.c ***/
// Description
// printenv - print the environment to stdout
// Synopsis
// printenv
// Build
// $ gcc -o printenv printenv.c
#include <stdio.h>
int main(int argc, char* argv[], char* envp[]) {
for (int i = 0;; ++i) {
char* p = envp[i];
if (p == NULL) break;
printf("%s\n", p);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment