std::basic_string::substr
提供: cppreference.com
< cpp | string | basic string
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
basic_string substr( size_type pos = 0, size_type count = npos ); |
||
部分文字列
[pos, pos+count)
を返します。要求された部分文字列が文字列の終わりを超えて続くか、またはcount == npos場合場合は、返される部分は[pos, size())
です. Original:
Returns a substring
[pos, pos+count)
. If the requested substring lasts past the end of the string, or if count == npos, the returned substring is [pos, size())
. The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
目次 |
[編集] パラメータ
pos | - | 搭載した最初の文字の位置
Original: position of the first character to include The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
count | - | 部分文字列の長さ
Original: length of the substring The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[編集] 値を返します
部分文字列を含む文字列
[pos, pos+count)
.Original:
String containing the substring
[pos, pos+count)
.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] 例外
std::out_of_range if pos > size().
[編集] 複雑
count
のリニアOriginal:
Linear in
count
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] 例
#include <string> #include <iostream> int main() { std::string a = "0123456789abcdefghij"; std::string sub1 = a.substr(10); std::cout << sub1 << '\n'; std::string sub2 = a.substr(5, 3); std::cout << sub2 << '\n'; std::string sub3 = a.substr(12, 100); std::cout << sub3 << '\n'; }
Output:
abcdefghij 567 cdefghij
[編集] も参照してください
コピー文字 Original: copies characters The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) |