Appendix A: System Routines — Strings
1001
TI
-
89 / TI
-
92 Plus Developer Guide
Not for Distribution
Beta Version January 26, 2001
strspn
Declaration:
size_t
strspn
(const char
*
s1
, const char
*
s2
)
Category(ies):
Strings
Description:
Calculates the length of a leading substring of the string pointed to by
s1
,
which consists entirely of characters in the string pointed to by
s2
.
Inputs:
s1
— Character string to search.
s2
— Character set.
Outputs:
Returns the length of the leading substring in
s1
that consists entirely of
characters in string
s2
. If
s1
contains no characters from
s2
, zero is
returned.
Assumptions:
None
Side Effects:
None
Availability:
All versions of the TI
-
89 / TI
-
92 Plus.
TI
-
89 / TI
-
92 Plus
Differences:
None
See Also: strcspn, strpbrk, strchr, strrchr, strstr, memchr
Example:
BOOL ck_octal( const char *str1, size_t *lenp )
/* ck_octal - Determine the length of a leading substring of a string that
consists of octal digits.
input: str1 = string to search
lenp = ptr to location to return length of substring
returns TRUE if str1 contains only octal digits, else FALSE
*/
{
if( ( *lenp = strspn(str1, "01234567")) == 0 )
return( FALSE ); /* no octal digits in str1 */
else if( *lenp == strlen(str1) )
return( TRUE ); /* str1 consists entirely of octal digits */
else
return( FALSE ); /* the first *lenp digits of str1 are octal */
}