finish part1 - to correct memchr & memcmp & strnstr
This commit is contained in:
12
Makefile
12
Makefile
@ -6,7 +6,7 @@
|
|||||||
# By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ #
|
# By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2023/11/01 11:03:22 by adjoly #+# #+# #
|
# Created: 2023/11/01 11:03:22 by adjoly #+# #+# #
|
||||||
# Updated: 2023/11/08 12:14:33 by adjoly ### ########.fr #
|
# Updated: 2023/11/08 17:07:14 by adjoly ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
@ -36,11 +36,13 @@ SRCS = ft_atoi.c \
|
|||||||
ft_strlcat.c \
|
ft_strlcat.c \
|
||||||
ft_strjoin.c \
|
ft_strjoin.c \
|
||||||
ft_strncmp.c \
|
ft_strncmp.c \
|
||||||
ft_strchr.c \
|
|
||||||
ft_itoa.c \
|
ft_itoa.c \
|
||||||
ft_calloc.c \
|
ft_calloc.c \
|
||||||
ft_memchr.c \
|
ft_memchr.c \
|
||||||
ft_memcmp.c \
|
ft_memcmp.c \
|
||||||
|
ft_strchr.c \
|
||||||
|
ft_strrchr.c \
|
||||||
|
ft_strnstr.c \
|
||||||
|
|
||||||
OBJS = $(SRCS:.c=.o)
|
OBJS = $(SRCS:.c=.o)
|
||||||
|
|
||||||
@ -51,9 +53,9 @@ HEADER = libft.h
|
|||||||
$(NAME): $(OBJS)
|
$(NAME): $(OBJS)
|
||||||
ar -rcs $(NAME) $(OBJS)
|
ar -rcs $(NAME) $(OBJS)
|
||||||
|
|
||||||
so:
|
# so:
|
||||||
$(CC) -nostartfiles -fPIC $(CFLAGS) $(SRCS)
|
# $(CC) -nostartfiles -fPIC $(CFLAGS) $(SRCS)
|
||||||
gcc -nostartfiles -shared -o libft.so $(OBJS)
|
# gcc -nostartfiles -shared -o libft.so $(OBJS)
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) $(FLAGS) -I $(HEADER) $< -c -o $@
|
$(CC) $(FLAGS) -I $(HEADER) $< -c -o $@
|
||||||
|
@ -6,12 +6,14 @@
|
|||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/05 14:52:53 by adjoly #+# #+# */
|
/* Created: 2023/11/05 14:52:53 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/08 11:59:58 by adjoly ### ########.fr */
|
/* Updated: 2023/11/08 14:52:06 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
|
|
||||||
|
#define BUFFER_SIZE 10
|
||||||
|
|
||||||
void *ft_memchr(const void *s, int c, size_t n)
|
void *ft_memchr(const void *s, int c, size_t n)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
15
ft_strchr.c
15
ft_strchr.c
@ -6,17 +6,18 @@
|
|||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/01 15:45:18 by adjoly #+# #+# */
|
/* Created: 2023/11/01 15:45:18 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/08 12:17:21 by adjoly ### ########.fr */
|
/* Updated: 2023/11/08 14:31:21 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
char *ft_strchr(const char *s, int c)
|
char *ft_strchr(const char *s, int c)
|
||||||
{
|
{
|
||||||
int i;
|
size_t len_s;
|
||||||
|
char *result;
|
||||||
|
|
||||||
i = 0;
|
len_s = ft_strlen(s);
|
||||||
while (s[i])
|
result = ft_memchr(s, c, len_s);
|
||||||
{
|
return (result);
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
4
libft.h
4
libft.h
@ -6,7 +6,7 @@
|
|||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/01 10:06:03 by adjoly #+# #+# */
|
/* Created: 2023/11/01 10:06:03 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/08 12:14:58 by adjoly ### ########.fr */
|
/* Updated: 2023/11/08 17:08:26 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -46,5 +46,7 @@ char *ft_itoa(int n);
|
|||||||
void *ft_memmove(void *dest, const void *src, size_t n);
|
void *ft_memmove(void *dest, const void *src, size_t n);
|
||||||
void *ft_memchr(const void *s, int c, size_t n);
|
void *ft_memchr(const void *s, int c, size_t n);
|
||||||
int ft_memcmp(const void *s1, const void *s2, size_t n);
|
int ft_memcmp(const void *s1, const void *s2, size_t n);
|
||||||
|
char *ft_strrchr(const char *s, int c);
|
||||||
|
char *ft_strnstr(const char *big, const char *little, size_t len);
|
||||||
|
|
||||||
#endif
|
#endif
|
Reference in New Issue
Block a user