Skip to content

Instantly share code, notes, and snippets.

@ajmontag
Created November 4, 2012 21:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajmontag/4013816 to your computer and use it in GitHub Desktop.
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.
/**
* 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