[Go to CFHT Home Page] Man Pages
Back to Software Index  BORDER=0Manpage Top Level
    basename(3G) manual page Table of Contents

Name

basename - return the last element of a path name

Synopsis

cc [ flag ... ] file ... -lgen [ library ... ]

#include <libgen.h>

char *basename(char *path);

MT-Level

MT-Safe

Description

Given a pointer to a null-terminated character string that contains a path name, basename() returns a pointer to the last element of path. Trailing ‘‘/’’ characters are deleted.

If path or *path is zero, pointer to a static constant ‘‘.’’ is returned.

Examples


Input string    Output pointer

/usr/lib    lib
/usr/    usr
/    /

See Also

basename(1) , dirname(3G)

Notes

When compiling multi-thread applications, the _REENTRANT flag must be defined on the compile line. This flag should only be used in multi-thread applications.


Table of Contents