Public domain
#include <stdio.h>
#include <unistd.h>
#define BUFSIZE 1024
int main()
{
char buffer[BUFSIZE];
readlink("/proc/self/exe", buffer, BUFSIZE);
printf("I am in %s\n", dirname(buffer));
return 0;
}
BY: Pejman Moghadam
TAG: proc, readlink, dirname
DATE: 2012-02-23 23:49:26