范例:
#include <string.h>
main()
{
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 /*只计算到“ ”的出现,所以返回“Linux”的长度*/
33 /*计算到出现“/”或“-”,所以返回到“6”的长度*/
30 /* 计算到出现数字字符为止,所以返回“3”出现前的长度*/
|