我是编程新手,我从Python开始。我正在尝试通过删除第一个和最后一个字符来缩短 C++ 中的字符串。
在Python中,我使用了[]运算符。 C++ 中有等效的吗?
我现在没有任何线索。
std::string_view
。
示例:
std::string const str = "~Hello World~";
std::string_view const view{std::next(str.begin()), std::prev(str.end())};
但请记住,如果绳子太短,它会在你脸上爆炸。