Appendix A: System Routines — Strings
1003
TI
-
89 / TI
-
92 Plus Developer Guide
Not for Distribution
Beta Version January 26, 2001
strtok
Declaration:
char *
strtok
(char *
str1
, const char *
str2
)
Category(ies):
Strings
Description:
The
strtok
function considers the string
str1
to consist of a sequence of
zero or more text tokens, separated by spans of one or more characters
from the string
str2
. The first call to
strtok
returns a pointer to the first
token in
str1
and writes a null character into
str1
immediately following the
returned token. Subsequent calls with NULL for the first argument will work
through string
str1
in this way until no tokens remain. The separator string
str2
may be different from call to call.
Inputs:
str1
— Character string or NULL.
str2
— Character string.
Outputs:
A pointer to the token found in
str1
is returned, NULL if there are no more
tokens.
Assumptions:
str1
points to a character string in RAM.
Side Effects:
None
Availability:
All versions of the TI-89 / TI-92 Plus.
TI-89 / TI-92 Plus
Differences:
None
See Also: strcspn, strspn
Example:
This example creates a string with all of the C "words" from a C program
and pushes it onto the estack.
char cpunct[] = " %,.()!=+-#<>{}*/'[];\n\\\"";
char testIn[] = "short test( char * arg1 ) { return strlen(arg1+1) };";
char testOut[256] = "";
char *token;
token = strtok( testIn, cpunct );
while (token != NULL) {
strcat( testOut, token );
strcat( testOut, " " );
token = strtok( NULL, cpunct );
}
/* Result is "short test char arg1 return strlen arg1 1" */
push_zstr( testOut );