Appendix A: System Routines — Strings
993
TI
-
89 / TI
-
92 Plus Developer Guide
Not for Distribution
Beta Version January 26, 2001
strcspn
Declaration:
size_t
strcspn
(const char
*
s1
, const char
*
s2
)
Category(ies):
Strings
Description:
Calculates the index of the first character in string
s1
that matches any of
the characters in string
s2
. This value is the length of a leading substring of
the string pointed to by
s1
which consists entirely of characters not in the
string pointed by
s2
.
Inputs:
s1
— Character string to search.
s2
— Character set.
Outputs:
Return the length of the substring in
s1
that consists entirely of characters
not found in string
s2
. If string
s1
contains no characters from string
s2
,
strcspn
returns the length of string
s1
.
Assumptions:
None
Side Effects:
None
Availability:
All versions of the TI
-
89 / TI
-
92 Plus.
TI
-
89 / TI
-
92 Plus
Differences:
None
See Also: strspn, strpbrk, strchr, strrchr, strstr, memchr
Example:
BOOL ck_vowel( const char *str1, size_t *lenp )
/* ck_vowel - Determine the length of a leading substring of a string that
contains no vowels.
input: str1 = string to search
lenp = ptr to location to return length of substring
returns TRUE if str1 contains a vowel, else FALSE
*/
{
if( ( *lenp = strcspn(str1, "aeiou")) == strlen(str1) )
return( FALSE ); /* no vowels in str1 */
else
return( TRUE ); /* str1 contains a vowel after *lenp nonvowels */
}