[英]Is there a std::string equivalent for CString::Mid()?
The equivalent would be std::string::substr
with the following interface:等效的将是具有以下接口的
std::string::substr
:
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.