-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strchr.c
36 lines (33 loc) · 1.15 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
36
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: emdi-mar <emdi-mar@student.42roma.it> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/08 17:45:07 by emdi-mar #+# #+# */
/* Updated: 2024/11/08 17:46:17 by emdi-mar ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strchr(const char *s, int c)
{
char *p;
char ch;
int found;
p = 0;
ch = c;
found = 0;
while (*s != '\0' && !found)
{
if (*s == ch)
{
p = (char *)s;
found = 1;
}
s++;
}
if (*s == '\0' && c == 0)
p = (char *)s;
return (p);
}