find the part of a string after the last "/"
#include <unistd.h> char *basename( char *string );
The basename() function is equivalent to 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.
#include <unistd.h> #include <stdio.h> int main( void ) { /* * 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/" ) ); return (EXIT_SUCCESS); }
QNX
Safety: | |
---|---|
Interrupt handler | Yes |
Signal handler | Yes |
Thread | Yes |
basename