-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strchr.c
More file actions
37 lines (34 loc) · 1.24 KB
/
ft_strchr.c
File metadata and controls
37 lines (34 loc) · 1.24 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
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_strchr.c :+: :+: */
/* +:+ */
/* By: farodrig <farodrig@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2020/11/27 11:16:53 by farodrig #+# #+# */
/* Updated: 2020/11/28 14:29:47 by farodrig ######## odam.nl */
/* */
/* ************************************************************************** */
/*
** Returns a pointer to the first occurrence of the character c
** in the string s. Returns a pointer to the matched character or NULL if
** the character is not found.
*/
char *ft_strchr(char *str, int c)
{
unsigned int i;
i = 0;
while (str[i] != '\0')
{
if (str[i] == c)
{
return (str + i);
}
i++;
}
if (str[i] == c)
{
return (str + i);
}
return (0);
}