size_t
strspn
(
const
char
*s,
const
char
* accept);
#include <string.h> #include <stdio.h> main() { char *str="Linux was first developed for 386/486-based pcs."; printf("%d\n",strspn(str,"Linux")); printf("%d\n",strspn(str,"/-")); printf("%d\n",strspn(str,"1234567890")); }
运行结果:
5
0
0
#include <string.h> main(void) { char *str = "Linux was first developed for 386/486-based pcs. "; printf("%d\n", strcspn(str, " ")); printf("%d\n", strcspn(str, "/-")); printf("%d\n", strcspn(str, "1234567890")); }
运行结果:
5
33
30