I would like to cast a wstring to size_t.
I have tried this:
wstring SomeWString=L"100";
size_t SomeValue;
SomeValue=_wtoi(SomeWString);
But that is not a valid conversion. VS2012 tells me:
There is no compatible conversion function for casting std::wstring to const_wchar_t*.
Can somebody please tell me how this should be done? Thank you very much.
_wtoi
expects an argument of type const wchar_t*
, but you're providing a wstring
.
Try the following:
SomeValue = _wtoi(SomeWString.c_str());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.