-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strchr.c
35 lines (34 loc) · 1.22 KB
/
ft_strchr.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mmalie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/07 08:45:01 by mmalie #+# #+# */
/* Updated: 2024/11/14 09:32:10 by mmalie ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
* Implementation of strchr() from <string.h>: Searches for the first
* occurrence of a character in a string.
*/
char *ft_strchr(const char *s, int c)
{
if (c < 0 || c > 255)
c = c % 256;
while (*s)
{
if (*s == (char)c)
{
return ((char *)s);
}
s++;
}
if (c == '\0')
{
return ((char *)s);
}
return (NULL);
}