-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strchr.c
More file actions
41 lines (37 loc) · 1.3 KB
/
ft_strchr.c
File metadata and controls
41 lines (37 loc) · 1.3 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sparth <sparth@student.42heilbronn.de> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/09 16:37:57 by sparth #+# #+# */
/* Updated: 2023/10/24 18:42:28 by sparth ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strchr(const char *s, int c)
{
char *string;
int i;
char check;
string = (char *) s;
check = (char) c;
i = 0;
while (string[i] != '\0')
{
if (string[i] == check)
return (string + i);
i++;
}
if (string[i] == check)
return (string + i);
return (NULL);
}
// #include <stdio.h>
// int main()
// {
// char string[] = "hello";
// printf("%s\n", ft_strchr(string, 'l'));
// return (0);
// }