Comparing 2 wchar_t arrays

走远了吗. 提交于 2019-12-01 17:12:50

问题


I'm sure this is sooo simple but I've come from a c# background where strings are easy and now I am making a small trip into the unmanaged world I am very confused.

Essentially I am using EnumDisplayDevices to list the available devices, I want to target a particular adapter so I need to compare DeviceString and DeviceName against some know values to see whether or not I have the right adapter to work on.

But I am stumped, I defined the known value as such...

wchar_t devName[] = L"Intel(R) HD Graphics Family";

but direct comparison doesn't work - if(devName == theDisplay.DeviceName)

strcmp doesnt seem to work with wide chars so I have no idea what to do, anyone know how to do this please?

Thanks


回答1:


Use a std::wstring, it has an operator==.




回答2:


If you check Visual Studio help for strcmp, you'll find it lists 3 functions to compare strings: strcmp, wcscmp and _mbscmp. The one you're looking for is wcscmp.



来源:https://stackoverflow.com/questions/7662048/comparing-2-wchar-t-arrays

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!