-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strchr.c
42 lines (37 loc) · 1.35 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sizerese <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/07 15:06:01 by sizerese #+# #+# */
/* Updated: 2023/08/04 20:13:24 by sizerese ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strchr(const char *str, int c)
{
int i;
unsigned char b;
i = 0;
b = (unsigned char) c;
while (str[i] != '\0')
{
if (b == str[i])
return ((char *)str + i);
i++;
}
if (str[i] == '\0' && b == '\0')
return ((char *)str + i);
return (0);
}
// int main(void)
// {
// // char str[] = "hello . t3here!";
// char s[] = "tripouille";
// // char find = ' ';
// char *ret;
// ret = ft_strchr(s, 256);
// printf("%s\n", ret);
// }