basename

find the part of a string after the last “/”

Synopsis:

#include <unistd.h>
char *basename( char *string );

Description:

The basename() function is a function equivalent of the 1003.2 basename utility. It returns a pointer to the first character following the last slash (/) found in string, or the first character of string if no slashes are found.

Returns:

a pointer to the basename portion of string

See also:

the 1003.2 basename utility

Examples:

#include <unistd.h>
#include  <stdio.h>

void main()
  {
    /*
     * basename returns a pointer to "three".
     */
    printf( "%s\n", basename( "one/two/three" ) );

    /*
     * basename returns a pointer to "one".
     */
    printf( "%s\n", basename( "one" ) );

    /*
     * basename returns a pointer to a null character.
     */
    printf( "%s\n", basename( "one/" ) );
  }

Classification:

QNX

Systems:

QNX