-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4-strpbrk.c
40 lines (34 loc) · 802 Bytes
/
4-strpbrk.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "main.h"
#include <stdio.h>
/**
* _strpbrk - Searches a string for any of a set of bytes
* @s: Source string to search
* @accept: Accepted characters
*
* Description: This function searches the given source string for the first
* occurrence of any character from the specified set of accepted
* characters. It returns a pointer to the location in the string
* where the first match is found.
*
* Return: Pointer to the location of the first found accepted character in the string,
* or NULL if no matches are found.
*/
char *_strpbrk(char *s, char *accept)
{
int a = 0, b;
while (s[a])
{
b = 0;
while (accept[b])
{
if (s[a] == accept[b])
{
s += a;
return (s);
}
b++;
}
a++;
}
return ('\0');
}