-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strchr.c
42 lines (38 loc) · 1.33 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: rnarciso <rnarciso@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/04 05:00:03 by rnarciso #+# #+# */
/* Updated: 2022/11/22 07:59:08 by rnarciso ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strchr(const char *str, int c)
{
size_t i;
i = 0;
while (str[i])
{
if (str[i] == (unsigned char)c)
return ((char *)str + i);
i++;
}
if (str[i] == (unsigned char)c)
return ((char *)str + i);
return (0);
}
/*
#include <stdio.h>
int main (void)
{
const char str[] = "This is just a String";
const char ch = 'T';
char *p;
p = ft_strchr(str, ch);
printf("String starting from %c is: %s\n", ch, p);
return 0;
}
*/