正在获取wchar_t []的子字符串

问题描述 投票:0回答:1

我有:

wchar_t str[32];

我想从位置0到5获得它的新子字符串。我该怎么做?

c++ string wchar-t
1个回答
0
投票

std::basic_string确实具有您要寻找的构造函数:

constexpr basic_string( const CharT* s,
                        size_type count,
                        const Allocator& alloc = Allocator() );

所以您可以这样做:

std::wstring substr{str, 5};
© www.soinside.com 2019 - 2024. All rights reserved.