-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strchr.c
43 lines (39 loc) · 1.45 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
40
41
42
43
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: antlopez <antlopez@student.42malaga.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/03 22:29:31 by antlopez #+# #+# */
/* Updated: 2022/12/03 22:29:33 by antlopez ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strchr(const char *s, int c)
{
int i;
i = 0;
while (s[i])
{
if (s[i] == (char)c)
return ((char *)&s[i]);
i++;
}
if ((char)c == 0)
return ((char *)&s[i]);
return (0);
}
// int main(void)
// {
// const char *s1 = "Hello World ?";
// char s2 = 'l';
// char s3 = '\0';
// char s[] = "tripouille";
// printf("%s\n", ft_strchr(s1, s2 + 256));
// printf("%s\n", ft_strchr(s1, s3));
// printf("%s\n", ft_strchr(s, 't' + 256));
// printf("%s\n", strchr(s1, s2 + 256));
// printf("%s\n", strchr(s1, s3));
// printf("%s\n", strchr(s, 't' + 256));
// }