-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathft_strchr.c
31 lines (29 loc) · 1.36 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apuchill <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/12/04 14:36:51 by apuchill #+# #+# */
/* Updated: 2020/02/19 15:10:09 by apuchill ### ########.fr */
/* */
/* ************************************************************************** */
/*
** LIBRARY: <string.h>
** SYNOPSIS: locate character in string (first occurrence)
**
** DESCRIPTION:
** The strchr() function 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 func-
** tions locate the terminating `\0'.
*/
char *ft_strchr(const char *s, int c)
{
while (*s != '\0' && c != *s)
s++;
if (c == *s)
return ((char *)s);
return (0);
}