码迷,mamicode.com
首页 > 其他好文 > 详细

strpbrk实现方式之一

时间:2015-04-19 16:19:57      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:

strpbrk

char *ho_strpbrk(const char *s1, const char *s2) {
    const char *s; 
    for (; *s1; s1++) {
        for (s = s2; *s; s++) {
            if (*s == *s1)
                return (char *)s1;
        }   
    }   
    return NULL;
}

int main() {

    printf("%s\n", strpbrk("12345678", "8"));
    printf("%s\n", strpbrk("12345678", "1"));
    printf("%s\n", strpbrk("12345678", "654"));
    printf("%s\n", strpbrk("12345678", "#"));

    printf("========\n");
    printf("%s\n", ho_strpbrk("12345678", "8"));
    printf("%s\n", ho_strpbrk("12345678", "1"));
    printf("%s\n", ho_strpbrk("12345678", "654"));
    printf("%s\n", ho_strpbrk("12345678", "#"));
    return 0;
}


strpbrk实现方式之一

标签:

原文地址:http://my.oschina.net/guonaihong/blog/403547

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!