当前位置: 技术问答>linux和unix
gcc如何得到执行程序的名字和路径
来源: 互联网 发布时间:2014-12-24
本文导语: 以前在dos下是用argv[0]得到执行程序和路径 现在在linux下用gcc好象只能得到执行程序名, 得不到执行程序所在路径,怎么办? | getcwd | getcwd() | getcwf | ...
以前在dos下是用argv[0]得到执行程序和路径
现在在linux下用gcc好象只能得到执行程序名,
得不到执行程序所在路径,怎么办?
现在在linux下用gcc好象只能得到执行程序名,
得不到执行程序所在路径,怎么办?
|
getcwd
|
getcwd()
|
getcwf
|
#include
char *getcwd(char *buf, size_t size);
char *get_current_dir_name(void);
char *getwd(char *buf);
DESCRIPTION
The getcwd() function copies an absolute pathname of the current working directory
to the array pointed to by buf, which is of length size.
If the current absolute path name would require a buffer longer than size elements,
NULL is returned, and errno is set to ERANGE; an application should check for this
error, and allocate a larger buffer if necessary.
If buf is NULL, the behaviour of getcwd() is undefined.
char *getcwd(char *buf, size_t size);
char *get_current_dir_name(void);
char *getwd(char *buf);
DESCRIPTION
The getcwd() function copies an absolute pathname of the current working directory
to the array pointed to by buf, which is of length size.
If the current absolute path name would require a buffer longer than size elements,
NULL is returned, and errno is set to ERANGE; an application should check for this
error, and allocate a larger buffer if necessary.
If buf is NULL, the behaviour of getcwd() is undefined.
|
see