wcstok

Section: C Library Functions (3)
Updated: 2026-02-08
Index JM Home Page roff page
 

名前

wcstok - ワイド文字文字列をトークンに分割する  

ライブラリ

標準 C ライブラリ (libc,~-lc)  

書式

#include <wchar.h>

wchar_t *wcstok(wchar_t *restrict wcs, const wchar_t *restrict delim,
                wchar_t **restrict ptr);
 

説明

wcstok() 関数は、 strtok(3) 関数に対応するワイド文字関数に、 マルチスレッドセーフの動作をさせるための引数を追加したものである。 この関数を用いて、ワイド文字文字列 wcs をトークンに分解すること ができる。ここで、トークンは delim に列挙されている文字を含まな い部分文字列として定義される。

The search starts at wcs, if wcs is not NULL, or at *ptr, if wcs is NULL. First, any delimiter wide-characters are skipped, that is, the pointer is advanced beyond any wide-characters which occur in delim. If the end of the wide-character string is now reached, wcstok() returns NULL, to indicate that no tokens were found, and stores an appropriate value in *ptr, so that subsequent calls to wcstok() will continue to return NULL. Otherwise, the wcstok() function recognizes the beginning of a token and returns a pointer to it, but before doing that, it zero-terminates the token by replacing the next wide-character which occurs in delim with a null wide character (L'\0'), and it updates *ptr so that subsequent calls will continue searching after the end of recognized token.  

返り値

wcstok() 関数は次のトークンへのポインターを返す。トークンが見つから なければ NULL を返す。  

属性

この節で使用されている用語の説明については、 attributes(7) を参照。
インターフェース属性値
wcstok() Thread safetyMT-Safe
 

標準規格

C11, POSIX.1-2008.  

歴史

POSIX.1-2001, C99.  

注意

関数に与えたワイド文字列 wcs は、関数の動作によって完全に書き換 えられる。  

例

以下のコードは、ワイド文字文字列に含まれるトークンを取り出しながら ループする。

wchar_t *wcs = ...;
wchar_t *token;
wchar_t *state;
for (token = wcstok(wcs, L" \t\n", &state);
    token != NULL;
    token = wcstok(NULL, L" \t\n", &state)) {
    ...
}
 

関連項目

strtok(3), wcschr(3)


 

Index

名前
ライブラリ
書式
説明
返り値
属性
標準規格
歴史
注意
例
関連項目

This document was created by man2html, using the manual pages.