English
Language : 

CC78K4 Datasheet, PDF (227/523 Pages) NEC – CC78K4 Ver.2.30 or Later, C Compiler Language
CHAPTER 10 LIBRARY FUNCTIONS
6-11 strtok
Character String/Memory Functions
FUNCTION
The string function strtok returns a pointer to a token taken from a string (by decomposing it into a string
consisting of characters other than delimiters).
HEADER
string. h
FUNCTION PROTOTYPE
char *strtok (char *s1, const char *s2);
Function
strtok
Arguments
s1... Pointer to string from
which tokens are to be
obtained or null pointer
s2 ... Pointer to string
containing delimiters of token
Return Value
• Pointer to the first character
of a token if it is found
• Null pointer if there is no
token to return
EXPLANATION
• A token is a string consisting of characters other than delimiters in the string to be specified.
• If s1 is a null pointer, the string pointed to by the saved pointer in the previous strtok call will be decomposed.
However, if the saved pointer is a null pointer, the function returns a null pointer without doing anything.
• If s1 is not a null pointer, the string pointed to by s1 will be decomposed.
• The strtok function searches the string pointed to by s1 for any character not contained in the string pointed
to by s2. If no character is found, the function changes the saved pointer to a null pointer and returns it. If
any character is found, the character becomes the first character of a token.
• If the first character of a token is found, the function searches for any characters contained in the string s2
after the first character of the token. If none of the characters is found, the function changes the saved pointer
to a null pointer. If any of the characters is found, the character is overwritten by a null character and a
pointer to the next character becomes a pointer to be saved.
• The function returns a pointer to the first character of the token.
User’s Manual U15556EJ1V0UM
227