Is there any equivalent function in std::string
for CString::mid()
?
The equivalent would be std::string::substr
with the following interface:
basic_string substr( size_type pos = 0, size_type count = npos ) const;
constexpr basic_string substr( size_type pos = 0, size_type count = npos ) const;
And you can use it like:
std::string str = "0123456789abcdefghij";
// returns [pos, size())
std::string sub1 = str.substr(10);
std::cout << sub1 << '\n';
// returns [pos, pos+count)
std::string sub2 = str.substr(5, 3);
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