-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strchr.c
39 lines (36 loc) · 1.36 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
37
38
39
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kakiba <kotto555555@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/12 00:07:37 by kakiba #+# #+# */
/* Updated: 2022/07/24 15:48:07 by kakiba ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strchr(const char *s, int c)
{
size_t i;
i = 0;
while (s[i] && s[i] != (char)c)
i++;
if (s[i] == (char)c)
return ((char *)(s + i));
return (NULL);
}
/*
int main()
{
char *s = "abcdefg";
//ordinary
printf("org_:%s\n", strchr(s, 'c'));
printf("ft__:%s\n", ft_strchr(s, 'c'));
//NULL
printf("org_:%s\n", strchr(s, '\0'));
printf("ft__:%s\n", ft_strchr(s, '\0'));
//nothing
printf("org_:%s\n", strchr(s, 'A'));
printf("ft__:%s\n", ft_strchr(s, 'A'));
}*/