Return the basename of a file
Prototype:   char * basename(char * name)
Parameters: name pointer to file name
Return Value: pointer to filename portion of *name
The unix shell command takes a path to a file and returns only the filename portion of it, discarding any directory names or suffixes.
The principal routine of this file, char * basename() does the same thing but is callable from a C program.
basename() is mostly used when displaying help messages, stripping the command name in argv[0] of all but the filename portion.

On Windows and VMS the input argument name string may be modified:
If it contains a file name extension (e.g. .exe) the dot (.) character delimiting that extension is replaced with a null character (\0), terminating the returned string at the beginning of the extension portion.

basename() compiles on Windows, Linux, Unix, OSX, and VMS.
Previous  |  Next ]     [ Up  |  First  |  Last ]     (Article 28 of 485)
Comments, flames, broken links?
Please send email to