Espaços nominais
Variantes
Acções

std::strtok

Da cppreference.com
< cpp‎ | string‎ | byte

 
 
Biblioteca cordas
Strings terminadas
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.
Cadeias de bytes
Multibyte cordas
Cordas de largura
Classes
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
 
Cordas de terminação nula de bytes
Funções
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Manipulação personagem
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.
Conversões para formatos numéricos
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.
Manipulação de cadeia
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
Exame String
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.
Manipulação de memória
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
Diversos
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 );
Localiza o próximo token em um byte string terminada em nulo apontado por str. Os caracteres separadores são identificados por terminada com null byte string apontado por delim.
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.
Se str != NULL, a função procura para o primeiro caractere que é não separador. Este personagem é o começo do token. Em seguida, a função pesquisa para o personagem primeiro separador. Este personagem é o fim do token. Função termina e retorna NULL se final de str é encontrada antes do fim' token é encontrada. Caso contrário, um ponteiro para fim da token é salvo em um local estático para chamadas subseqüentes. Este personagem é então substituída por um NULL caracteres ea função retorna um ponteiro para o início do sinal.
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.
Se str == NULL, a função continua de onde saiu em chamada anterior. O comportamento é o mesmo que o ponteiro se previamente armazenado é passado como 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.

Índice

[editar] Parâmetros

str -
ponteiro para o byte string terminada em nulo para tokenize
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 -
ponteiro para o byte string terminada em nulo identificar delimitadores
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.

[editar] Valor de retorno

Apontador para o início de um símbolo se o fim da cadeia não tenha sido encontrada. Caso contrário, retorna 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.

[editar] Nota

A função não é thread-safe.
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.

[editar] Exemplo

#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

[editar] Veja também

C documentation for strtok