-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strchr.c
34 lines (30 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: anarodri <anarodri@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/09/23 15:15:48 by anarodri #+# #+# */
/* Updated: 2022/12/15 12:51:09 by anarodri ### ########.fr */
/* */
/* ************************************************************************** */
/*
Locates the first occurrence of c (converted to a char) in the string.
The terminating null character is considered to be part of the string.
Return: pointer to the first occurrence of the character c in the string str,
or NULL if the character is not found.
*/
#include "../libft.h"
char *ft_strchr(const char *str, int c)
{
char *chr;
chr = (char *)str;
while (*chr != (unsigned char)c)
{
if (*chr == '\0')
return (NULL);
chr++;
}
return (chr);
}