-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strchr.c
33 lines (30 loc) · 1.18 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hmontoya <hmontoya@student.42barcel> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/10 19:51:02 by hmontoya #+# #+# */
/* Updated: 2023/06/14 19:26:58 by hmontoya ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strchr(const char *s, int c)
{
unsigned char *str;
unsigned char ch;
int i;
str = (unsigned char *) s;
ch = (unsigned char) c;
i = 0;
while (str[i])
{
if (str[i] == ch)
return ((char *)str + i);
i++;
}
if (ch == '\0')
return ((char *)str + i);
return (NULL);
}