std::strtok
De cppreference.com
[] |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody>| Dclar dans l'en-tte <cstring>
|
||
char* strtok( char* str, const char* delim ); |
||
Trouve le jeton suivant dans une chane d'octets termine par zro point par
str. Les caractres de sparation sont identifis par une chane d'octets termine par zro 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.
You can help to correct and verify the translation. Click here for instructions.
Si
str != NULL, la fonction recherche pour le premier caractre qui n'est pas sparateur. Ce caractre est le dbut de la' jeton. Ensuite, la fonction recherche pour le caractre premier sparateur. Ce personnage est la fin de la' jeton. Fonction termine et renvoie NULL si la fin de str est rencontre 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 remplace par une valeur NULL caractres et la fonction retourne un pointeur vers le dbut 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.
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 prcdente. Le comportement est le mme que si le pointeur prcdemment mmorise 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.
You can help to correct and verify the translation. Click here for instructions.
Paramtres
| str | - | pointeur vers la chane d'octets termine 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 chane d'octets termine par NULL identifier dlimiteurs
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. |
Retourne la valeur
Pointeur vers le dbut d'un jeton, si la fin de la chane n'a pas t rencontre. 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.
You can help to correct and verify the translation. Click here for instructions.
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.
You can help to correct and verify the translation. Click here for instructions.
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, " ");
}
}
Rsultat :
A
bird
came
down
the
walk
Voir aussi
C documentation for strtok
|