Compares the first n wide characters of two strings
#include <wchar.h>
int wcsncmp ( const wchar_t *s1 , const wchar_t *s2 , size_t n );
The wcsncmp( ) function compares at most the first n wide characters in the two strings addressed by its pointer arguments. Characters that follow a null wide character are ignored. wcsncmp( ) returns a value indicating the result as follows:
Zero
The two wide strings, or arrays of n wide characters, are equal.
Greater than zero
The string or array of n wide characters addressed by s1 is greater than that addressed by s2.
Less than zero
The string or array of n wide characters addressed by s1 is less than that addressed by s2.
Example
wchar_t *months[ ] = { L"January", L"February", L"March", L"April",
L"May", L"June", L"July", L"August",
L"September", L"October", L"November", L"December" };
wchar_t date[ ] = L"Thu, 10 Mar 2005 13:44:18 +0100";
int mo = 0;
while (( mo < 12 ) && ( wcsncmp( date + 8, months[mo], 3 ) != 0 ))
mo++;
See Also
wcscmp( ), wcscoll( ), strncmp( ), strcmp( )
|