gpt4 book ai didi

c++ - wstring 到 size_t

转载 作者:行者123 更新时间:2023-11-30 02:50:09 25 4
gpt4 key购买 nike

我想将一个 wstring 转换为 size_t。

我试过这个:

wstring SomeWString=L"100";
size_t SomeValue;
SomeValue=_wtoi(SomeWString);

但这不是有效的转换。 VS2012 告诉我:

There is no compatible conversion function for casting std::wstring to const_wchar_t*.

有人可以告诉我应该怎么做吗?非常感谢。

最佳答案

_wtoi 需要类型为 const wchar_t* 的参数,但您提供的是 wstring

尝试以下操作:

SomeValue = _wtoi(SomeWString.c_str());

关于c++ - wstring 到 size_t,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20661192/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com