Espaces de noms
Variantes
Affichages
Actions

std::strtok

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

 
 
Bibliothèque de chaînes de caractères
Chaînes à zéro terminal
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.
Les chaînes d'octets
Chaines multi-octets
Les chaînes étendues
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
 
Chaînes d'octets à zéro terminal
Fonctions
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Manipulation caractère
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.
Conversion aux formats numériques
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.
La manipulation de chaînes
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
Examen chaîne
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.
Manipulation de la mémoire
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
Divers
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
 
Déclaré dans l'en-tête <cstring>
char* strtok( char* str, const char* delim );
Trouve le jeton suivant dans une chaîne d'octets terminée par zéro pointé par str. Les caractères de séparation sont identifiés par une chaîne d'octets terminée par zéro pointé par 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.
Si str != NULL, la fonction recherche pour le premier caractère qui n'est pas séparateur. Ce caractère est le début de la' jeton. Ensuite, la fonction recherche pour le caractère premier séparateur. Ce personnage est la fin de la' jeton. Fonction termine et renvoie NULL si la fin de str est rencontrée avant la fin de la' token est trouvé. Sinon, un pointeur vers la fin de la' jeton est enregistré dans un emplacement fixe pour les appels suivants. Ce personnage est alors remplacée par une valeur NULL caractères et la fonction retourne un pointeur vers le début de la' jeton .
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.
Si str == NULL, la fonction reprend là où il a quitté l'invocation précédente. Le comportement est le même que si le pointeur précédemment mémorisée est passé comme 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.

Sommaire

[modifier] Paramètres

str -
pointeur vers la chaîne d'octets terminée par NULL pour tokenizer
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 -
pointeur vers la chaîne d'octets terminée par NULL identifier délimiteurs
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.

[modifier] Retourne la valeur

Pointeur vers le début d'un jeton, si la fin de la chaîne n'a pas été rencontrée. Sinon retourne 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.

[modifier] Note

La fonction n'est pas 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.

[modifier] Exemple

#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, " ");
    }
}

Résultat :

A
bird
came
down
the
walk

[modifier] Voir aussi

C documentation for strtok