C Standard Libraries C++

wcscoll()

Declaration

int wcscoll(const wchar_t* kwpString1, const wchar_t* kwpString2);

Description

This function compares the two null-terminated, wide-character strings "kwpString1" and "kwpString2" on a character by character basis, using the current locale to determine which one is less/greater than the other. The function returns a value less than 0, equal to zero, or greater than zero, depending on whether the first string is less than, equal to, or greater than the second string, respectively.

Example

#include <cwchar>

int main()
{
    wchar_t waWideString1[] = L"XoaX.net";
    wchar_t waWideString2[] = L"Video Tutorials";

    // Compare String 1 and String 2
    int iComparison = wcscoll(waWideString1, waWideString2);
    wprintf(L"Comparison Value = %d\n", iComparison);
    // Compare String 1 with itself
    iComparison = wcscoll(waWideString1, waWideString1);
    wprintf(L"Comparison Value = %d\n", iComparison);
    // Compare String 2 and String 1
    iComparison = wcscoll(waWideString2, waWideString1);
    wprintf(L"Comparison Value = %d\n", iComparison);

    // Keep the window open until "Enter" is pressed
    getwchar();
    return 0;
}

Output

wcscoll() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.