Returns an absolute pathname from the POSIX root. Format #include <stdlib.h> char realpath (const char *restrict file_name, char *restrict resolved_name);
1 – Arguments
file_name Pointer to the text string representing the name of the file for which you want the absolute path. resolved name Pointer to the generated absolute path stored as a null- terminated string.
2 – Description
The realpath function returns an absolute pathname from the POSIX root. The generated pathname is stored as a null-terminated string, up to a maximum of PATH_MAX bytes, in the buffer pointed to by resolved_name. The realpath function is supported only in POSIX-compliant modes (that is, with DECC$POSIX_COMPLIANT_PATHNAMES defined to one of the allowed values). See also symlink, unlink, readlink, lchown, and lstat.
3 – Return Values
x Upon successful completion, a pointer to the resolved_name. NULL Indicates an error. A null pointer is returned, the contents of the buffer pointed to by resolved_name are undefined, and errno is set to indicate the error: o ENAMETOOLONG - The length of the file_name argument exceeds PATH_MAX, or a pathname component is longer than NAME_MAX. o ENOENT - A component of file_name does not name an existing file, or file_name points to an empty string. o Any errno value from chdir or stat.