Created
August 28, 2013 05:49
-
-
Save Ayrx/6362515 to your computer and use it in GitHub Desktop.
A simple piece of C code to print out the memory address of a specific environmental variable.
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
#include <stdlib.h> | |
#include <stdio.h> | |
int main(int argc, char *argv[]) { | |
char *addr; | |
if (argc < 2) { | |
printf("Usage:\n%s <environment variable name>\n", argv[0]); | |
exit(0); | |
} | |
addr = getenv(argv[1]); | |
if (addr == NULL) | |
printf("The environment variable %s doesn't exist.\n", argv[1]); | |
else | |
printf("%s is located at %p\n", argv[1], addr); | |
return(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment