Possible Duplicate:
how to check string start in C++
I need to check if wstring begins with a particular string.
const wstring str = "Hello World";
wstring temp="Hello ";
How I can check str
begins with temp
or not?
Use wide literals for starters; then it's a breeze:
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 */ }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With