Previous Page
Next Page


Searches for the rightmost occurrence of a given wide character in a string

#include <wchar.h>
wchar_t *wcsrchr ( const wchar_t *s , wchar_t wc  );

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 = wmyname;
  wprintf( L"This program was invoked as %ls.\n", mybasename );

See Also

wcschr( ), wcsstr( ), wcsspn( ), wcscspn( ), wcspbrk( ); the byte character string functions strchr( ), strrchr( ), strpbrk( ), strstr( ), strspn( ), strcspn( )

Previous Page
Next Page