#include <string.h>
size_t strspn(const char *s, const char *accept);
#include <stdio.h>
#include <string.h>
int main()
{
char *str = "hello linux world";
printf("%d\n", strspn(str, "hello"));
printf("%d\n", strspn(str, "zyxwvutsrqponmlkjhgfedcba")); /* str 中有空格,accept 在检测时遇到空格停止*/
printf("%d\n", strspn(str, "abcdefghjklmnopqrstuvwxyz ")); /* 这里的 accept 少了一个字符 'i' */
printf("%d\n", strspn(str, "abcdefghijklmnopqrstuvwxyz ")); /* str 中的字符在 accept 里都能找得到*/
return 0;
}
./strspn
5
5
7
17
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |