Returns the last component of a pathname. Format #include <libgen.h> char *basename (char *path);
1 – Function Variants
The basename function has variants named _basename32 and _basename64 for use with 32-bit and 64-bit pointer sizes, respectively.
2 – Argument
path A UNIX style pathname from which the base pathname is extracted.
3 – Description
The basename function takes the UNIX style pathname pointed to by path and returns a pointer to the pathname's final component, deleting any trailing slash (/) characters. 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.
4 – Return Values
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.