English
Language : 

CC78K4 Datasheet, PDF (224/523 Pages) NEC – CC78K4 Ver.2.30 or Later, C Compiler Language
CHAPTER 10 LIBRARY FUNCTIONS
6-8 strspn,
strcspn
Character String/Memory Functions
FUNCTION
The string function strspn returns the length of the initial substring of a string that is made up of only those
characters contained in another string.
The string function strcspn returns the length of the initial substring of a string that is made up of only those
characters not contained in another string.
HEADER
string. h
FUNCTION PROTOTYPE
size_t strspn (const char *s1, const char *s2);
size_t strcspn (const char *s1, const char *2);
Function
strspn
strcspn
Arguments
s1... Pointer to string to be
searched
s2 ... Pointer to string whose
characters are specified for
match
Return Value
Length of substring of the
string s1 that is made up of
only those characters
contained in the string s2
Length of substring of the
string s1 that is made up of
only those characters not
contained in the s2
EXPLANATION
strspn
• The strspn function returns the length of the substring of the string pointed to by s1 that is made up of only
those characters contained in the string pointed to by s2. In other words, this function returns the index of the
first character in the string s1 that does not match any of the characters in the string s2.
• The null terminator of s2 is not regarded as part of s2.
strcspn
• The strcspn function returns the length of the substring of the string pointed to by s1 that is made up of only
those characters not contained in the string pointed to by s2. In other words, this function returns the index of
the first character in the string s1 that matches any of the characters in the string s2.
• The null terminator of s2 is not regarded as part of s2.
224
User’s Manual U15556EJ1V0UM