-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strchr.c
27 lines (24 loc) · 1.21 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gpiccion <[email protected]. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/18 12:23:40 by gpiccion #+# #+# */
/* Updated: 2021/11/18 12:23:40 by gpiccion ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
// Returns a pointer to the first occurrence of the char 'c' in 'str'.
// If no match is found, returns NULL.
char *ft_strchr(const char *str, int c)
{
int i;
i = 0;
while (str[i] && (char)str[i] != (char)c)
i++;
if ((char)str[i] == (char)c)
return ((char *)&str[i]);
return (NULL);
}