Namensräume
Varianten
Aktionen

std::strtok

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

 
 
Strings Bibliothek
Null-terminierte Strings
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.
Byte-Strings
Multibyte-Strings
Wide Strings
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
 
Null-terminierte Byte-Strings
Funktionen
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Character Manipulation
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.
Umwandlungen in numerische Formate
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.
String-Manipulation
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
String Prüfung
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.
Speicher Manipulation
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
Verschiedenes
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 );
Sucht das nächste Token in einem Null-terminierte Byte String, auf den str. Die Trennzeichen werden durch nullterminierten byte String, auf den delim identifiziert .
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.
Wenn str != NULL, durchsucht die Funktion für das erste Zeichen, das nicht Separator. Dieses Zeichen ist das Anfang der Token. Dann wird die Funktion sucht nach dem ersten Trennzeichen. Dieses Zeichen ist das Ende des Tokens. Funktion beendet und gibt NULL, wenn Ende str angetroffen wird, bevor Ende des Tokens gefunden wird. Andernfalls wird ein Zeiger auf Ende des Tokens in einer statischen Position zur nachfolgenden Aufrufen gespeichert. Dieses Zeichen wird dann durch ein NULL-Zeichen ersetzt und die Funktion gibt einen Zeiger auf die Anfang der Token .
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.
Wenn str == NULL weiterhin die Funktion, von wo es nach links in vorherigen Aufruf. Das Verhalten ist das gleiche wie bei der zuvor gespeicherte Zeiger als str geleitet wird .
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.

Inhaltsverzeichnis

[Bearbeiten] Parameter

str -
Zeiger auf die null-terminierte Byte-String in Token aufzuteilen
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 -
Zeiger auf die null-terminierte Byte-Zeichenfolge, die Trennzeichen
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.

[Bearbeiten] Rückgabewert

Zeiger auf den Beginn eines Token, wenn das Ende der Zeichenkette nicht angetroffen wurde. Ansonsten kehrt 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.

[Bearbeiten] Hinweis

Die Funktion ist nicht Thread-sicher .
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.

[Bearbeiten] Beispiel

#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

[Bearbeiten] Siehe auch

C documentation for strtok