How to compare wide character strings in C++

1 Answer

0 votes
#include <iostream>
#include <cwchar>

int main() {
    wchar_t str1[] = L"c++ programming";
    wchar_t str2[] = L"java programming";

    std::wcout << wcscmp(str1, str2) << "\n";
    std::wcout << wcscmp(str2, str1) << "\n";
    std::wcout << wcscmp(str1, str1);
}




/*
run:

-1
1
0

*/

 



answered Nov 27, 2022 by avibootz

Related questions

1 answer 174 views
174 views asked Aug 7, 2024 by avibootz
1 answer 243 views
243 views asked Jun 22, 2017 by avibootz
1 answer 215 views
1 answer 188 views
188 views asked Aug 7, 2024 by avibootz
1 answer 213 views
213 views asked Jun 22, 2017 by avibootz
2 answers 294 views
...