int wmemcmp(const wchar_t* kwpBuffer1, const wchar_t* kwpBuffer2, size_t uiCompSize);
#include <cwchar> int main() { wchar_t waBuffer1[] = L"XoaXAlgorithms"; wchar_t waBuffer2[] = 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, waBuffer1, waBuffer2); int iCompValue = wmemcmp(waBuffer1, waBuffer2, 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, waBuffer1, waBuffer2); iCompValue = wmemcmp(waBuffer1, waBuffer2, 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, waBuffer2, waBuffer1); iCompValue = wmemcmp(waBuffer2, waBuffer1, 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.