LabWindows/CVI

Content Type
Programming Language
Current manual

strtok

strtok

char *strtok (char stringToSeparate[], const char setOfDelimiters[]);

Purpose

Breaks a string into tokens, which are sequences of contiguous characters separated by one or more characters from the specified set of delimiters. To find all tokens in a string, you must call strtok in a loop, once for each token. The first call has the original string as the first argument and is followed by calls with a NULL pointer as their first arguments. The set of delimiters can vary from call to call. If a character in the delimiter set is found, it is overwritten by an ASCII NUL byte, which terminates the current token. A pointer to the next character is saved, from which the next search for a token will start.

Parameters

Input
Name Type Description
stringToSeparate char [] Contains a pointer to the string that contains the tokens. Any character in this string that matches one found in the specified set of delimiters is overwritten with an ASCII NUL byte. To find all of the tokens in a string, subsequent calls must have NULL entered into this parameter, to continue searching where the last successful function call ended.
Note Note  The contents of this string are modified by this function.
setOfDelimiters const char [] Contains the set of delimiters that are searched for in the specified string. During a sequence of calls in which all tokens for a string are found, the contents of this set can vary.

Return Value

Name Type Description
currentToken char * Contains a pointer to the first character of the current token or a NULL pointer if there is no token.

Additional Information

Library: ANSI C Library

Include file: ansi_c.h

LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later

Examples

Refer to the following examples that use the strtok function:

  • udp\DNSResolver.cws

    Open example
  • userint\timeaxis.cws

    Open example
Was this information helpful?