Previous Page
Next Page


Searches for a given character in a string

#include <wchar.h>
wchar_t *wcschr ( const wchar_t *s , wchar_t c  );

The wcschr( ) function returns a pointer to the first occurrence of the wide character value c in the wide string addressed by s. If there is no such character in the string, wcschr( ) returns a null pointer. If c is a null wide character (L'\0'), then the return value points to the terminator character of the wide string addressed by s.


typedef struct {
  wchar_t  street[32];
  wchar_t  city[32];
  wchar_t  stateprovince[32];
  wchar_t  zip[16];
} Address;

wchar_t printaddr[128] = L"720 S. Michigan Ave.\nChicago, IL 60605\n";
int sublength;
Address *newAddr = calloc( 1, sizeof(Address) );

if ( newAddr != NULL )
  sublength = wcschr( printaddr, L'\n' ) - printaddr;
  wcsncpy( newAddr->street, printaddr, (sublength < 31 ? sublength : 31) );
  /* ... */

See Also

strchr( ), wcsrchr( )

Previous Page
Next Page