-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strchr.c
32 lines (28 loc) · 1.26 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: inwagner <inwagner@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/03 18:10:37 by inwagner #+# #+# */
/* Updated: 2023/06/09 18:37:55 by inwagner ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strchr(const char *src, int c)
{
size_t i;
if (!c)
return ((char *)&src[ft_strlen(src)]);
i = 0;
while (src[i] && src[i] != (char)(c))
i++;
if (src[i] == (char)(c))
return ((char *)&src[i]);
return (0);
}
/*
Procura na string `s` pela primeira ocorrência do caractere `c`.
Retorna um ponteiro para o caractere localizado na string ou nulo caso não ache.
*/