Guardian C Library Calls Reference Manual
Reference to Library Calls
Guardian TNS C Library Calls Reference Manual—128833 3-211
strtok
strtok
The strtok function gets a token from a specified string. 
str1_ptr
is either a pointer to the source string for the first token or a null pointer for 
subsequent tokens.
str2_ptr
points to a string that specifies the list of token delimiter characters; these characters 
cannot be part of a token.
Return Value
points to the next token in the string. strtok returns the pointer value NULL when 
there are no remaining tokens.
Usage Guidelines
•
The first call to strtok returns a pointer to the first character of the first token.
•
The strtok function writes a null character to *str1_ptr immediately following the 
token.
•
You can return subsequent tokens by passing NULL as the first argument.
Example
This example gets a token from string token:
#include <stringh>
#include <stdioh>
int main(void)
{
 char *object, *separators, *token;
 object = "alpha = beta + 123;";
 separators = " ;"; /* list of token separators */
 token = strtok(object, separators);
 while (token != NULL)
 {
 printf("%s\n",token);
 token = strtok(NULL, separators);
 }
}
#include <stringh>
char *strtok(char *str1_ptr, const char *str2_ptr);










