Created
November 4, 2012 21:18
-
-
Save ajmontag/4013816 to your computer and use it in GitHub Desktop.
A simple C program to compare different ways of getting your program's name in unix.
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
/** | |
* A simple program to compare different ways of getting your program's name. | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
extern char* __progname; | |
extern char* program_invocation_name; | |
extern char* program_invocation_short_name; | |
int main(int argc, char** argv) | |
{ | |
printf("argv[0]\n\t%s\n", argv[0]); | |
printf("__progname\n\t%s\n", __progname); | |
printf("program_invocation_name\n\t%s\n", program_invocation_name); | |
printf("program_invocation_short_name\n\t%s\n", program_invocation_short_name); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment