可能重复:
如何在C++中检查字符串start
我需要检查wstring是否以特定字符串开头.
const wstring str = "Hello World";
wstring temp="Hello ";
Run Code Online (Sandbox Code Playgroud)
我怎么检查str
开始temp
与否?
Ker*_* SB 10
为初学者使用宽文字; 然后这是一件轻而易举的事:
std::wstring const str = L"Hello World";
// one method:
if (str.substr(0, 6) == L"Hello ") { /* yay */ }
// another method, better:
if (str.find(L"Hello ") == 0) { /* hooray */ }
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4480 次 |
最近记录: |