FreeBSD Manual Pages
std::wmemcmp(3) C++ Standard Libary std::wmemcmp(3) NAME std::wmemcmp - std::wmemcmp Synopsis Defined in header <cwchar> int wmemcmp( const wchar_t* lhs, const wchar_t* rhs, std::size_t count ); Compares the first count wide characters of the wide character ar- rays pointed to by lhs and rhs. The comparison is done lexicographically. The sign of the result is the sign of the difference between the values of the first pair of wide characters that differ in the arrays being compared. If count is zero, the function does nothing. Parameters lhs, rhs - pointers to the wide character arrays to compare count - number of wide characters to examine Return value Negative value if the value of the first differing wide character in lhs is less than the value of the corresponding wide character in rhs: lhs pre- cedes rhs in lexicographical order. 0 if all count wide characters of lhs and rhs are equal. Positive value if the value of the first differing wide character in lhs is greater than the value of the corresponding wide character in rhs: rhs pre- cedes lhs in lexicographical order. Notes This function is not locale-sensitive and pays no attention to the values of the wchar_t objects it examines: nulls as well as invalid wide charac- ters are compared too. Example // Run this code #include <iostream> #include <string> #include <cwchar> #include <locale> #include <clocale> void demo(const wchar_t* lhs, const wchar_t* rhs, std::size_t sz) { std::wcout << std::wstring(lhs, sz); int rc = std::wmemcmp(lhs, rhs, sz); if(rc == 0) std::wcout << " compares equal to "; else if(rc < 0) std::wcout << " precedes "; else if(rc > 0) std::wcout << " follows "; std::wcout << std::wstring(rhs, sz) << " in lexicographical or- der\n"; } int main() { std::setlocale(LC_ALL, "en_US.utf8"); std::wcout.imbue(std::locale("en_US.utf8")); wchar_t a1[] = {L'',L'',L''}; constexpr std::size_t sz = sizeof a1 / sizeof *a1; wchar_t a2[sz] = {L'',L'',L''}; demo(a1, a2, sz); demo(a2, a1, sz); demo(a1, a1, sz); } Possible output: precedes in lexicographical order follows in lexicographical order compares equal to in lexicographical order See also wcscmp compares two wide strings (function) memcmp compares two buffers (function) wcsncmp compares a certain amount of characters from two wide strings (function) http://cppreference.com 2022.07.31 std::wmemcmp(3)
NAME | Synopsis | Parameters | Return value | Notes | Example | Possible output: | See also
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::wmemcmp&sektion=3&manpath=FreeBSD+Ports+15.0>
