diff options
Diffstat (limited to 'src/string/strpbrk.c')
| -rw-r--r-- | src/string/strpbrk.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/string/strpbrk.c b/src/string/strpbrk.c new file mode 100644 index 00000000..0b88b999 --- /dev/null +++ b/src/string/strpbrk.c @@ -0,0 +1,28 @@ +#include <string.h> +#include "nonstd/assert.h" + +/** count matching characters **/ +char * strpbrk(const char *s1, const char *s2) +{ + size_t i; + + ASSERT_NONNULL(s1); + ASSERT_NONNULL(s2); + + for (i = 0; i < strlen (s1); i++) { + if (strchr(s2, s1[i]) != NULL) { + return (char*)s1 + i; + } + } + + return NULL; +} + +/*** +locates the first occurence in ARGUMENT(s1) of any character in ARGUMENT(s2). +***/ +/* + RETURN_FAILURE(CONSTANT(NULL)); + RETURN_SUCCESS(a pointer to the located character); +STDC(1) +*/ |
