-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strchr.c
More file actions
37 lines (34 loc) · 1.44 KB
/
ft_strchr.c
File metadata and controls
37 lines (34 loc) · 1.44 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lcosta-g <lcosta-g@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/09 13:04:24 by lcosta-g #+# #+# */
/* Updated: 2024/10/15 16:23:47 by lcosta-g ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strchr(const char *s, int c)
{
while (*s && *s != (unsigned char)c)
s++;
if (*s == (unsigned char)c)
return ((char *)s);
return (NULL);
}
/*
#include <stdio.h>
int main(void)
{
printf("%s\n", ft_strchr("ABC", 'B')); // BC
printf("%s\n", ft_strchr("ABC", 'Z')); // (null)
printf("%s\n", ft_strchr("ABC", 'a')); // (null)
printf("%s\n", ft_strchr("ABCABC", 'C')); // CABC
printf("%s\n", ft_strchr("", '\0')); // \0
printf("%s\n", ft_strchr("test", '\0')); // \0
printf("%s\n", ft_strchr("\0", '\0')); // \0
return (0);
}
*/