-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strchr.c
35 lines (32 loc) · 1.17 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: twakrim <taha.wakrim.pro@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/10/11 17:28:27 by twakrim #+# #+# */
/* Updated: 2018/10/28 01:18:26 by twakrim ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strchr(const char *s, int c)
{
int i;
char cherchedchar;
char *str;
i = 0;
str = (char *)s;
cherchedchar = (char)c;
while (s[i] != '\0')
{
if (s[i] == cherchedchar)
{
return (str + i);
}
i++;
}
if (cherchedchar == '\0')
return (str + i);
return (NULL);
}