Guardian C Library Calls Reference Manual

strspn
3-208 128833Guardian TNS C Library Calls Reference Manual
Reference to Library Calls
strspn
The strspn function scans a string until it finds a character that is not found in another
specified string.
str1_ptr
points to the string to scan.
str2_ptr
points to the string containing the characters to scan for.
Return Value
is the length of the initial segment of *str1_ptr that consists entirely of characters in
*str2_ptr.
Example
This example scans string s and finds 10 characters before it encounters a character that
is not also in string i:
#include <stringh>
#include <stdioh>
int main(void)
{
size_t length;
char *s;
char *i;
s="An example: how to use strspn";
i="ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz";
length = strspn(s,i);
printf("%d",length); /* prints "10" */
}
#include <stringh>
size_t strspn(const char *str1_ptr, const char *str2_ptr);