find the part of a string after the last “/”
#include <unistd.h> char *basename( char *string );
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.
a pointer to the basename portion of string
the 1003.2 basename utility
#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/" ) ); }
QNX
QNX