-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strchr.c
38 lines (35 loc) · 1.22 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gudaniel <gudaniel@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/09 13:58:42 by gudaniel #+# #+# */
/* Updated: 2024/04/09 13:58:45 by gudaniel ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strchr(const char *str, int r)
{
int i;
char *p;
p = (char *)str;
i = 0;
while ((unsigned char)str[i] != (unsigned char)r)
{
if (!str[i])
return (0);
i++;
p++;
}
return (p);
}
/* int main()
{
char *s = "Gustavo";
char c = 'u';
printf("%s\n", ft_strchr(s, c));
printf("%s", strchr(s, c));
return(0);
} */