(ANSI Standard)
#include <string.h> i = strcspn( s, stop );
"strcspn" scans through "s" and finds the first character in "s" that also appears in "stop". It returns the position of that character within "s". Another way of saying this is that "strcspn" returns the number of characters at the beginning of "s" that are NOT found in "stop". For example,
j = strcspn(s," ");
determines how many characters occur before the first blank in "s".
The '\0' at the end of "stop" is considered to be part of "stop". Thus if "s" doesn't contain any of the other characters in "stop", "strcspn" will return the position of the '\0' at the end of "s" (which means that "strcspn" returns the length of "s").
Copyright © 1996, Thinkage Ltd.