pmg*_*pmg 20
该realpath()
功能未在C标准中描述.然而,它由POSIX 1997和POSIX 2008描述.如果这就是你的意思,这是一个例子:
#include <limits.h> /* PATH_MAX */
#include <stdio.h>
#include <stdlib.h>
int main(void) {
char buf[PATH_MAX]; /* PATH_MAX incudes the \0 so +1 is not required */
char *res = realpath("this_source.c", buf);
if (res) {
printf("This source is at %s.\n", buf);
} else {
perror("realpath");
exit(EXIT_FAILURE);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
PATH_MAX在<limits.h>中定义(<limits.h>来自POSIX 1997)