memchr & memcmp finish
This commit is contained in:
6
Makefile
6
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/06 17:37:53 by adjoly ### ########.fr #
|
# Updated: 2023/11/08 12:14:33 by adjoly ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
@ -39,6 +39,8 @@ SRCS = ft_atoi.c \
|
|||||||
ft_strchr.c \
|
ft_strchr.c \
|
||||||
ft_itoa.c \
|
ft_itoa.c \
|
||||||
ft_calloc.c \
|
ft_calloc.c \
|
||||||
|
ft_memchr.c \
|
||||||
|
ft_memcmp.c \
|
||||||
|
|
||||||
OBJS = $(SRCS:.c=.o)
|
OBJS = $(SRCS:.c=.o)
|
||||||
|
|
||||||
@ -49,7 +51,7 @@ 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)
|
||||||
|
|
||||||
|
11
ft_memchr.c
11
ft_memchr.c
@ -6,7 +6,7 @@
|
|||||||
/* 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/06 15:37:15 by adjoly ### ########.fr */
|
/* Updated: 2023/11/08 11:59:58 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -14,13 +14,16 @@
|
|||||||
|
|
||||||
void *ft_memchr(const void *s, int c, size_t n)
|
void *ft_memchr(const void *s, int c, size_t n)
|
||||||
{
|
{
|
||||||
int i;
|
size_t i;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < n && ((unsigned char *)s)[i] && ((char *)s) != c)
|
while (((char *)s)[i] && i < n)
|
||||||
{
|
{
|
||||||
s++;
|
if (((char *)s)[i] == (char)c)
|
||||||
|
return (((char *)s + i));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
if (c == 0)
|
||||||
|
return (((char *)s) + i);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
18
ft_strchr.c
18
ft_strchr.c
@ -6,17 +6,17 @@
|
|||||||
/* 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/05 21:33:16 by adjoly ### ########.fr */
|
/* Updated: 2023/11/08 12:17:21 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
// char *ft_strchr(const char *s, int c)
|
char *ft_strchr(const char *s, int c)
|
||||||
// {
|
{
|
||||||
// int i;
|
int i;
|
||||||
|
|
||||||
// i = 0;
|
i = 0;
|
||||||
// while (s[i])
|
while (s[i])
|
||||||
// {
|
{
|
||||||
|
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
3
libft.h
3
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/06 11:03:52 by adjoly ### ########.fr */
|
/* Updated: 2023/11/08 12:14:58 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -45,5 +45,6 @@ void *ft_memchr(const void *s, int c, size_t n);
|
|||||||
char *ft_itoa(int n);
|
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);
|
||||||
|
|
||||||
#endif
|
#endif
|
Reference in New Issue
Block a user