-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strchr.c
42 lines (38 loc) · 1.34 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: sabraham <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/29 23:45:04 by sabraham #+# #+# */
/* Updated: 2023/08/12 18:54:39 by sabraham ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strchr(const char *str, int c)
{
int i;
int len;
unsigned char b;
i = 0;
len = ft_strlen(str);
b = (unsigned char) c;
while (i <= len)
{
if (str[i] == b)
{
return ((char *)&str[i]);
}
i++;
}
return (NULL);
}
// int main()
// {
// const char str[] = "http://www.tutorialspoint.com";
// const char ch = 't';
// printf("%s\n", ft_strchr(str, ch));
// printf("%s\n", strchr(str, ch));
// return 0;
// }