C Standard Libraries C++



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


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.


#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
    return 0;


wcscoll() Output

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