-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strchr.c
More file actions
36 lines (32 loc) · 1.4 KB
/
ft_strchr.c
File metadata and controls
36 lines (32 loc) · 1.4 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fsanz-ex <fsanz-ex@student.42madrid.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/26 15:12:18 by fsanz-ex #+# #+# */
/* Updated: 2023/02/09 20:14:13 by fsanz-ex ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*Locates the first occurrence of c (converted to a char) in the string pointed
to by s. The terminating null character is considered to be part of the string;
therefore if c is `\0', the functions locate the terminating `\0'. Returns a
pointer to the located character, or NULL if the character does not appear in
the string.*/
char *ft_strchr(const char *s, int c)
{
int i;
char *st;
i = 0;
st = (char *) s;
while (i <= ft_strlen(s))
{
if (*st == (char) c)
return (st);
st++;
i++;
}
return (NULL);
}