Scroll to navigation

wcstok(3) Library Functions Manual wcstok(3)

NOME

wcstok - separa uma string de caracteres largos em tokens

BIBLIOTECA

Biblioteca C Padrão (libc, -lc)

SINOPSE

#include <wchar.h>
wchar_t *wcstok(wchar_t *restrict wcs, const wchar_t *restrict delim,
                wchar_t **restrict ptr);

DESCRIÇÃO

A função wcstok() é o equivalente de caracteres largos da função strtok(), com um argumento adicional para torná-la segura para multithread. Ela pode ser usada para separar uma string de caracteres largos wcs em tokens, onde um token é definido como uma substring que não contém nenhum dos caracteres largos de 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.

VALOR DE RETORNO

A função wcstok() retorna um ponteiro para o próximo token, ou NULO se nenhum token adicional foi encontrado.

ATRIBUTOS

Para uma explicação dos termos usados nesta seção, consulte attributes(7).

Interface Atributo Valor
wcstok() Thread safety MT-Safe

PADRÕES

C11, POSIX.1-2008.

HISTÓRICO

POSIX.1-2001, C99.

NOTAS

A string de caracteres largos original wcs é modificada destrutivamente durante a operação.

EXEMPLOS

O seguinte código percorre os tokens contidos numa string de caracteres largos.

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)) {
... }

VEJA TAMBÉM

strtok(3), wcschr(3)

TRADUÇÃO

A tradução para português brasileiro desta página man foi criada por Felipe M Pereira <Felipe.Pereira@ic.unicamp.br>, André Luiz Fassone <lonely_wolf@ig.com.br> e Rafael Fontenelle <rafaelff@gnome.org>.

Esta tradução é uma documentação livre; leia a Licença Pública Geral GNU Versão 3 ou posterior para as condições de direitos autorais. Nenhuma responsabilidade é aceita.

Se você encontrar algum erro na tradução desta página de manual, envie um e-mail para a lista de discussão de tradutores.

20 julho 2023 Linux man-pages 6.05.01