名前空間
変種
操作

std::strtok

提供: cppreference.com
< cpp‎ | string‎ | byte

 
 
ストリングスライブラリ
NULLで終わる文字列
Original:
Null-terminated strings
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
バイト文字列
文字列をマルチバイト
ワイド文字列
クラス
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string
char_traits
 
NULL終端バイト文字列
機能します
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
文字操作
Original:
Character manipulation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
数値形式への変換
Original:
Conversions to numeric formats
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
文字列操作
Original:
String manipulation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
strcpy
strncpy
strcat
strncat
strxfrm
文字列の検査
Original:
String examination
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
メモリ操作
Original:
Memory manipulation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
memchr
memcmp
memset
memcpy
memmove
その他
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
strerror
 
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.
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.
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.

目次

[編集] パラメータ

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.

[編集] 注意してください

関数はスレッドセーフではありません.
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.

[編集]

#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