ft_strchr: initial implementation
This commit is contained in:
parent
1eb276c8cf
commit
3754c47e8c
3 changed files with 50 additions and 3 deletions
5
Makefile
5
Makefile
|
|
@ -6,7 +6,7 @@
|
||||||
# By: kcolin <marvin@42.fr> +#+ +:+ +#+ #
|
# By: kcolin <marvin@42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2024/10/14 13:43:59 by kcolin #+# #+# #
|
# Created: 2024/10/14 13:43:59 by kcolin #+# #+# #
|
||||||
# Updated: 2024/10/16 10:30:28 by kcolin ### ########.fr #
|
# Updated: 2024/10/16 10:46:03 by kcolin ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
|
@ -25,7 +25,8 @@ SOURCES = ft_isalpha.c \
|
||||||
ft_strlcpy.c \
|
ft_strlcpy.c \
|
||||||
ft_strlcat.c \
|
ft_strlcat.c \
|
||||||
ft_toupper.c \
|
ft_toupper.c \
|
||||||
ft_tolower.c
|
ft_tolower.c \
|
||||||
|
ft_strchr.c
|
||||||
OBJECTS = $(SOURCES:.c=.o)
|
OBJECTS = $(SOURCES:.c=.o)
|
||||||
CC = gcc
|
CC = gcc
|
||||||
|
|
||||||
|
|
|
||||||
44
ft_strchr.c
Normal file
44
ft_strchr.c
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_strchr.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: kcolin <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/10/16 10:34:23 by kcolin #+# #+# */
|
||||||
|
/* Updated: 2024/10/16 10:42:16 by kcolin ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
char *ft_strchr(const char *s, int c)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (s[i] != '\0')
|
||||||
|
{
|
||||||
|
if (s[i] == c)
|
||||||
|
return ((char *)s + i);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
char *result;
|
||||||
|
|
||||||
|
if (argc > 2)
|
||||||
|
{
|
||||||
|
result = ft_strchr(argv[1], argv[2][0]);
|
||||||
|
if (result == 0)
|
||||||
|
printf("(null)\n");
|
||||||
|
else
|
||||||
|
printf("%s\n", result);
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
*/
|
||||||
4
libft.h
4
libft.h
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: kcolin <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/10/15 10:11:54 by kcolin #+# #+# */
|
/* Created: 2024/10/15 10:11:54 by kcolin #+# #+# */
|
||||||
/* Updated: 2024/10/16 10:24:26 by kcolin ### ########.fr */
|
/* Updated: 2024/10/16 10:34:08 by kcolin ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -33,4 +33,6 @@ t_size ft_strlcat(char *dst, const char *src, t_size size);
|
||||||
int ft_toupper(int c);
|
int ft_toupper(int c);
|
||||||
int ft_tolower(int c);
|
int ft_tolower(int c);
|
||||||
|
|
||||||
|
char *ft_strchr(const char *s, int c);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue