-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strchr.c
45 lines (41 loc) · 1.45 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
45
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dpaluszk <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/08 12:28:13 by dpaluszk #+# #+# */
/* Updated: 2024/03/18 17:08:52 by dpaluszk ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strchr(const char *s, int c)
{
size_t i;
i = 0;
while (s[i] != '\0')
{
if (s[i] == (char)c)
return ((char *)&s[i]);
i++;
}
if ((char)c == '\0')
return ((char *)&s[i]);
return (NULL);
}
// int main()
// {
// char *word = "truskawka";
// int d = '\0';
// char *result = ft_strchr(word, d);
// if (result != NULL)
// {
// printf("Character '%c' found at position: %ld\n", *result, result - word);
// }
// else
// {
// printf("Character '%c' not found in the string.\n", d);
// }
// return (0);
// }