Created
March 8, 2013 17:43
-
-
Save chaitanyav/5118288 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* | |
* Author: NagaChaitanya Vellanki | |
* | |
* | |
* display environment variables | |
* | |
*/ | |
#include<stdio.h> | |
#include<stdlib.h> | |
extern char **environ; | |
int main(int argc, char *argv[], char *envp[]) { | |
char **ep; | |
/* 1st way */ | |
fprintf(stdout, "******************************************\n\ | |
Printing environment variables using char **environ\n\ | |
******************************************************\n"); | |
for(ep = environ; *ep != NULL; ep++) { | |
fprintf(stdout, "%s\n", *ep); | |
} | |
fprintf(stdout, "\n\n"); | |
/* 2nd way */ | |
fprintf(stdout, "****************************************\n\ | |
Printing environment variables using char *envp[]\n\ | |
************************************************\n"); | |
for(ep = envp; *ep != NULL; ep++) { | |
fprintf(stdout, "%s\n", *ep); | |
} | |
exit(EXIT_SUCCESS); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment