std::strtok
提供:cppreference.com
|
|
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. |
| Defined in header <cstring>
|
||
| char* strtok( char* str, const char* delim ); |
||
strが指すNULL終端バイト文字列で次のトークンを検索します。区切り文字はdelimが指すNULL終端バイト文字列によって識別されます.Original:
Finds the next token in a null-terminated byte string pointed to by
str. The separator characters are identified by null-terminated byte string pointed to by delim.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.
str != NULL場合、この関数は'セパレーターではない最初の文字を検索します。この文字は、トークンのの始まりです。この関数は最初の区切り文字を検索します。この文字は、トークンのエンドです。関数は終了し、トークンの終わりが検出される前にNULLの終わりが検出された場合
strを返します。そうでなければ、トークンの端にポインタが後続の呼び出しのための静的な場所に保存されます。この文字は、その後、NULL文字で置き換え、関数はトークンのの先頭へのポインタを返します。.Original:
If str != NULL, the function searches for the first character which is not separator. This character is the beginning of the token. Then the function searches for the first separator character. This character is the end of the token. Function terminates and returns NULL if end of
str is encountered before end of the token is found. Otherwise, a pointer to end of the token is saved in a static location for subsequent invocations. This character is then replaced by a NULL-character and the function returns a pointer to the beginning of the token.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.
str == NULL場合、この関数は、以前の呼び出しで中断したところから続けています。以前に保存されたポインタがstrとして渡されているかのように振る舞いは同じです.
Original:
If str == NULL, the function continues from where it left in previous invocation. The behavior is the same as if the previously stored pointer is passed as str.
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.
目次 |
[編集] パラメータ
| str | - | トークン化するNULL終端バイト文字列へのポインタ
Original: pointer to the null-terminated byte string to tokenize The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| delim | - | 区切り文字を識別するNULL終端バイト文字列へのポインタ
Original: pointer to the null-terminated byte string identifying delimiters The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[編集] 値を返します
文字列の終わりが検出されていない場合、トークンの先頭へのポインタ。さもなければNULL返し.
Original:
Pointer to the beginning of a token if the end of string has not been encountered. Otherwise returns NULL.
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.
[編集] 注意してください
関数はスレッドセーフではありません.
Original:
The function is not thread safe.
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 <cstring> #include <iostream> int main() { char input[100] = "A bird came down the walk"; char *token = std::strtok(input, " "); while (token != NULL) { std::cout << token << '\n'; token = std::strtok(NULL, " "); } }
Output:
A bird came down the walk
[編集] も参照してください
| C documentation for strtok
|