int wcsncmp(const wchar_t* kqpString1, const wchar_t* kqpString2, size_t uiCompSize);
#include <cwchar> int main() { wchar_t waString1[] = L"XoaXAlgorithms"; wchar_t waString2[] = L"XoaXArchitecture"; size_t uiCompSize = 5; // Compare the first 5 characters (should be the same) wprintf(L"The first %u characters of \"%ws\" vs \"%ws\"\n", uiCompSize, waString1, waString2); int iCompValue = wcsncmp(waString1, waString2, uiCompSize); wprintf(L"Comparison value = %d\n", iCompValue); // Increase the number of characters to compare uiCompSize = 6; wprintf(L"The first %u characters of \"%ws\" vs \"%ws\"\n", uiCompSize, waString1, waString2); iCompValue = wcsncmp(waString1, waString2, uiCompSize); wprintf(L"Comparison value = %d\n", iCompValue); // Reverse the order of comparison wprintf(L"The first %u characters of \"%ws\" vs \"%ws\"\n", uiCompSize, waString2, waString1); iCompValue = wcsncmp(waString2, waString1, uiCompSize); wprintf(L"Comparison value = %d\n", iCompValue); // Keep the window open until "Enter" is pressed getwchar(); return 0; }
© 20072024 XoaX.net LLC. All rights reserved.