strrpbrk.c
来自「c语言库函数!里面包含了所以c语言中的系统函数的实现及其详细说明和代码!请大家及」· C语言 代码 · 共 53 行
C
53 行
/* +++Date last modified: 05-Jul-1997 */
/*
** strrpbrk() - reverse of strpbrk() - Finds the last occurrence of
** any characters from szChars found in szString.
**
** Donated to SNIPPETS by Phi Nguyen 1995, modified by Bob Stout
*/
#include <stdio.h>
#include <string.h>
#include "snip_str.h"
#if defined(__cplusplus) && __cplusplus
extern "C" {
#endif
char *strrpbrk(const char *szString, const char *szChars)
{
const char *p;
char *p0, *p1;
for (p = szChars, p0 = p1 = NULL; p && *p; ++p)
{
p1 = strrchr(szString, *p);
if (p1 && p1 > p0)
p0 = p1;
}
return p0;
}
#if defined(__cplusplus) && __cplusplus
}
#endif
#ifdef TEST
main()
{
char string[] = "This is a testing string",
chars[] = "xyzet",
*ptr;
ptr = strrpbrk(string, chars);
if (ptr)
printf("One or more of \"%s\" found at \"%s\"\n", chars, ptr);
else printf("Can't find any of \"%s\" in \"%s\".\n", chars, string);
return 0;
}
#endif /* TEST */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?