This repository was archived by the owner on Nov 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathft_strchr.c
More file actions
44 lines (39 loc) · 1.33 KB
/
ft_strchr.c
File metadata and controls
44 lines (39 loc) · 1.33 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
38
39
40
41
42
43
44
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mcombeau <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/22 13:53:33 by mcombeau #+# #+# */
/* Updated: 2021/12/05 15:35:48 by mcombeau ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
DESCRIPTION :
The function ft_strchr finds the first occurence of character c in
string str.
RETURN VALUE :
A pointer to the first occurence of c in str.
NULL if c is not found.
*/
char *ft_strchr(const char *str, int c)
{
int i;
unsigned char ch;
i = 0;
ch = c;
if (ch == '\0')
{
i = ft_strlen(str);
return ((char *)str + i++);
}
while (str[i])
{
if (str[i] == ch)
return ((char *)str + i);
i++;
}
return (NULL);
}