Guardian C Library Calls Reference Manual

Reference to Library Calls
Guardian TNS C Library Calls Reference Manual128833 3-197
strcspn
strcspn
The strcspn function scans a string until it finds a character that is 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 the *str1_ptr that consists entirely of
characters not listed in *str2_ptr.
Example
This example scans string s and finds 10 characters before it encounters a character that
is also in string i:
#include <stringh>
#include <stdioh>
int main(void)
{
size_t length;
char *s;
char *i;
s = "An example: how to use strcspn";
i = ",.;:";
length = strcspn(s,i);
printf("%d",length); /* prints "10" */
}
#include <stringh>
size_t strcspn(const char *str1_ptr, const char *str2_ptr);