December 2005
Beginner to intermediate
618 pages
20h 19m
English
wcsrchr
Searches for the rightmost occurrence of a given wide character in a string
#include <wchar.h> wchar_t *wcsrchr( const wchar_t *s, wchar_twc);
The wcsrchr() function
returns a pointer to the last occurrence of the
wide character value wc in the string
addressed by s. If there is no such wide
character in the string, wcsrchr() returns a null pointer. If
wc is a null wide character (L'\0'), then the return value points to
the terminator of the string addressed by
s.
int main( int argc, char ** argv )
{
wchar_t wmyname[256];
size_t result = mbstowcs( wmyname, argv[0], 256 );
if ( result == -1 )
return -1;
wchar_t *mybasename =wcsrchr( wmyname, L'/' ); // End of path
if ( mybasename != NULL )
mybasename++;
else
mybasename = wmyname;
wprintf( L"This program was invoked as %ls.\n", mybasename );
}Read now
Unlock full access