Format
#include <wcstr.h> int wcscmp(const wchar_t *string1, const wchar_t *string2);
Language Level: ANSI
Threadsafe: Yes.
Description
The wcscmp() function compares two wide-character strings. The wcscmp()function operates on null-ended wchar_t strings; string arguments to this function should contain a wchar_t null character marking the end of the string. Boundary checking is not performed when a string is added to or copied.
Return Value
The wcscmp() function returns a value indicating the relationship between the two strings, as follows:
Example that uses wcscmp()
This example compares the wide-character string string1 to string2 using wcscmp().
#include <stdio.h> #include <wcstr.h> int main(void) { int result; wchar_t string1[] = L"abcdef"; wchar_t string2[] = L"abcdefg"; result = wcscmp( string1, string2 ); if ( result == 0 ) printf( "\"%ls\" is identical to \"%ls\"\n", string1, string2); else if ( result < 0 ) printf( "\"%ls\" is less than \"%ls\"\n", string1, string2 ); else printf( "\"%ls\" is greater than \"%ls\"\n", string1, string2); } /**************** Output should be similar to: ****************** "abcdef" is less than "abcdefg" */
Related Information
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.