@c ---------------------------------------------------------------------- @node basename, file system @subheading Syntax @example #include char * basename (const char *fname); @end example @subheading Description This function returns the @dfn{basename} of the file, which is the last part of its full name given by @var{fname}, with the drive letter and leading directories stripped off. For example, the basename of @code{c:/foo/bar/file.ext} is @code{file.ext}, and the basename of @code{a:foo} is @code{foo}. Trailing slashes and backslashes are significant: the basename of @code{c:/foo/bar/} is an empty string after the rightmost slash. This function treats both forward- and backslashes like directory separators, so it can handle file names with mixed styles of slashes. @subheading Return Value A pointer into the original file name where the basename starts. Note that this is @strong{not} a new buffer allocated with @code{malloc}. If @var{fname} is a NULL pointer, the function will return a NULL pointer. @subheading Portability @portability !ansi, !posix @subheading Example @example if (strcmp (basename (file_name), "gcc.exe") == 0) printf ("The file %s is the GNU C/C++ compiler\n", file_name); @end example