Chinaunix首页 | 论坛 | 博客
  • 博客访问: 383921
  • 博文数量: 55
  • 博客积分: 1907
  • 博客等级: 上尉
  • 技术积分: 869
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-04 19:30
文章分类

全部博文(55)

文章存档

2011年(32)

2010年(23)

分类: C/C++

2010-11-28 19:03:18

/*
 * Find the first occurrence in 'str' of any of the characters in 'chars' and
 * return a poniter to the location. If none are found, or if 'str' or 'chars'
 * NULL pointers, a NULL pointer is returned.
 *
 * 2010-11-20
 * got it.
 */

#define NULL 0


    /* 返回指针的函数 */
char *find_char( char const *str, char const *chars )
{
    char *cp;
    
    /* check arguments for NULL */
    if( str != NULL && chars != NULL )
    {
        for( ; *str != NULL; str++ )
        {
            for( cp = chars; *cp != '\0'; cp++ )
                if( *str == *cp )
                    return str;
        }    
    }
    return NULL;
}


阅读(1143) | 评论(1) | 转发(0) |
0

上一篇:动态内存分配之11.5

下一篇:指针之6.2

给主人留下些什么吧!~~

chinaunix网友2010-12-01 14:58:36

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com