-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strchr.c
44 lines (41 loc) · 1.89 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
32
33
34
35
36
37
38
39
40
41
42
43
44
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mbutt <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/27 20:00:45 by mbutt #+# #+# */
/* Updated: 2019/03/14 15:46:06 by mbutt ### ########.fr */
/* */
/* ************************************************************************** */
/*
** 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 functions locate the
** terminating `\0'.
** The strrchr() function is identical to strchr(), except it locates the last
** occurrence of c.
** RETURN VALUES: The functions strchr() and strrchr() return a pointer to the
** located character, or NULL if the character does not appear in the string.
*/
#include "libft.h"
char *ft_strchr(const char *s, int c)
{
return (ft_memchr(s, c, ft_strlen(s) + 1));
}
/*
** int main (void)
** {
** const char *string1 = "there is so \0ma\0ny \0 \\0 in t\0his stri\0ng";
** int c1 = '\0';
** const char *string2 = "there is so \0ma\0ny \0 \\0 in t\0his stri\0ng";
** int c2 = '\0';
** const char *string3 = "This is a test.";
** int c3 = ' ';
** printf("%s\n", strchr(string1, c1));
** printf("%s\n", ft_strchr(string2, c2));
** printf("%s", ft_strchr(string3, c3));
** return(0);
**}
*/