Returns the last component of a path name.
#include <libgen.h> char *basename (char *path);Function Variants This function also has variants named _basename32 and _basename64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.8 for more information on using pointer-size-specific functions.
If path consists entirely of the slash (/) character, the function returns a pointer to the string "/".
If path is a NULL pointer or points to an empty string, the function returns a pointer to the string ".".
The basename function can modify the string pointed to by path.
x | A pointer to the final component of path. |
"/" | If path consists entirely of the '/' character. |
"." | If path is a NULL pointer or points to an empty string. |