December 2005
Beginner to intermediate
618 pages
20h 19m
English
wcschr
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.
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) );
/* ... */
}Read now
Unlock full access