0
点赞
收藏
分享

微信扫一扫

字符串 操作函数 strchr 实现

老罗话编程 2022-08-10 阅读 42


/*
The strchr() and strrchr() functions return a pointer to the matched character or NULL
if the character is not found.
*/
char *strchr_r(const char *str, int c)
{
if(!str)
return NULL;

char ch = (char)c;

while((*str) && ((*str) != ch))
str++;
if((*str) == ch)
return (char *)str;

return NULL;
}


举报

相关推荐

0 条评论