[출처] : https://kldp.org/node/48280
1 #include <stdio.h> 2 #include <sys/param.h> 3 #include <stdlib.h> 4 5 int main(char *argc, char *argv[]) 6 { 7 char resolved_path[MAXPATHLEN]; 8 9 printf("%s, %s\n", argv[0], __FILE__); 10 realpath(argv[0], resolved_path); 11 printf("resolved_path: %s\n", resolved_path); 12 13 return 0; 14 }
$ ./a.out ./a.out, test.c resolved_path: /usr/home/whitekid/a.out
'Programming > C/C++' 카테고리의 다른 글
ffmpeg tutorial (0) | 2016.05.13 |
---|---|
gettimeofday를 대체하는 clock_gettime 함수 (0) | 2014.12.22 |
std::find 클래스 멤버로 찾기 (0) | 2014.12.11 |
c언어 매크로 사용법 - 1. #, ## 연산자 (0) | 2014.12.05 |
HEX dump (0) | 2014.12.01 |