ft_memchr, norming ft_memmove

This commit is contained in:
Tanguy MAZE 2018-04-06 16:50:41 +02:00
parent 6e3cc9928d
commit a380be6a68
3 changed files with 30 additions and 3 deletions

View File

@ -6,7 +6,7 @@
# By: tmaze <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2018/04/04 10:51:59 by tmaze #+# #+# #
# Updated: 2018/04/06 15:11:37 by tmaze ### ########.fr #
# Updated: 2018/04/06 16:12:43 by tmaze ### ########.fr #
# #
#******************************************************************************#
@ -22,6 +22,7 @@ SRCS = \
ft_memcpy.c \
ft_memccpy.c \
ft_memmove.c \
ft_memchr.c \
ft_strlen.c \
ft_strdup.c \
ft_strcpy.c \

26
ft_memchr.c Normal file
View File

@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/06 16:07:52 by tmaze #+# #+# */
/* Updated: 2018/04/06 16:27:54 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memchr(const void *s, int c, size_t n)
{
int i;
char *tmp;
i = -1;
tmp = (char*)s;
while ((unsigned int)++i < n)
if ((char)tmp[i] == (char)c)
return ((void*)&tmp[i]);
return (NULL);
}

View File

@ -6,7 +6,7 @@
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/06 15:06:49 by tmaze #+# #+# */
/* Updated: 2018/04/06 15:20:29 by tmaze ### ########.fr */
/* Updated: 2018/04/06 16:50:07 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,5 +19,5 @@ void *ft_memmove(void *dst, const void *src, size_t len)
i = 0;
while (++i <= len)
((char*)dst)[i - 1] = ((char*)src)[i - 1];
return (dst);
return (dst);
}