-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strchr.c
More file actions
26 lines (23 loc) · 1.08 KB
/
ft_strchr.c
File metadata and controls
26 lines (23 loc) · 1.08 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cmachado <cmachado@student.42lisboa.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/20 14:10:15 by cmachado #+# #+# */
/* Updated: 2022/02/25 22:55:23 by cmachado ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strchr(const char *s, int c)
{
char *ptr;
size_t cnt;
ptr = (char *)s;
cnt = ft_strlen(s) + 1;
while (cnt-- > 0)
if (*ptr++ == (char)c)
return (--ptr);
return (NULL);
}