Repository navigation
Expand file tree
/
Copy pathft_strchr.c
More file actions
44 lines (36 loc) · 1.39 KB
/
Copy pathft_strchr.c
File metadata and controls
44 lines (36 loc) · 1.39 KB
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
44
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: smasatak <smasatak@student.42tokyo.jp> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/04/28 16:22:16 by smasatak #+# #+# */
/* Updated: 2026/06/24 06:13:22 by smasatak ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strchr(const char *s, int c)
{
while (*s != '\0')
{
if (*s == (char)c)
return ((char *)s);
s++;
}
if (*s == (char)c)
return ((char *)s);
return (NULL);
}
// #include <stdio.h>
// int main(void)
// {
// char str[] = "Hello.";
// printf("%s\n", ft_strchr(str, 'e'));
// printf("%s\n", strchr(str, 'e'));
// printf("%s\n", ft_strchr(str, '\0'));
// printf("%s\n", strchr(str, '\0'));
// printf("%s\n", ft_strchr(str, 'x'));
// printf("%s\n", strchr(str, 'x'));
// return (0);
// }