Name
wcschr
Synopsis
Searches for a given character in a string
#include <wchar.h> wchar_t *wcschr
( const wchar_t *s
, wchar_tc
);
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
.
Example
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) );
/* ... */
}
Get C in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.