d
This commit is contained in:
parent
1d0f0b1901
commit
8735f25286
14
Makefile
14
Makefile
@ -6,7 +6,7 @@
|
|||||||
# By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ #
|
# By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2022/09/27 08:39:27 by cchauvet #+# #+# #
|
# Created: 2022/09/27 08:39:27 by cchauvet #+# #+# #
|
||||||
# Updated: 2022/09/27 16:08:49 by cchauvet ### ########.fr #
|
# Updated: 2022/09/27 17:11:15 by cchauvet ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
@ -28,13 +28,11 @@ SRCS = ft_isalpha.c \
|
|||||||
ft_memchr.c \
|
ft_memchr.c \
|
||||||
ft_memcmp.c \
|
ft_memcmp.c \
|
||||||
ft_strdup.c \
|
ft_strdup.c \
|
||||||
ft_calloc.c
|
|
||||||
|
|
||||||
COMMENT = ft_strlcpy.c \
|
|
||||||
ft_strlcat.c \
|
ft_strlcat.c \
|
||||||
ft_strnstr.c \
|
|
||||||
ft_atoi.c \
|
ft_atoi.c \
|
||||||
ft_strdup.c
|
ft_memccpy.c \
|
||||||
|
ft_calloc.c \
|
||||||
|
ft_strlcpy.c
|
||||||
|
|
||||||
OBJS = ${SRCS:.c=.o}
|
OBJS = ${SRCS:.c=.o}
|
||||||
|
|
||||||
@ -60,5 +58,5 @@ re:
|
|||||||
ar rc ${NAME}.a ${OBJS}
|
ar rc ${NAME}.a ${OBJS}
|
||||||
|
|
||||||
so:
|
so:
|
||||||
$(CC) -nostartfiles -fPIC $(CFLAGS) $(SRC)
|
gcc -nostartfiles -fPIC $(CFLAG) $(SRCS)
|
||||||
gcc -nostartfiles -shared -o libft.so $(OBJ)
|
gcc -nostartfiles -shared -o libft.so $(OBJS)
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/09/27 16:14:34 by cchauvet #+# #+# */
|
/* Created: 2022/09/27 16:14:34 by cchauvet #+# #+# */
|
||||||
/* Updated: 2022/09/27 16:22:36 by cchauvet ### ########.fr */
|
/* Updated: 2022/09/27 16:45:19 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -18,8 +18,9 @@ int ft_atoi(const char *nptr)
|
|||||||
int out;
|
int out;
|
||||||
int sign;
|
int sign;
|
||||||
|
|
||||||
|
str = (char *) nptr;
|
||||||
out = 0;
|
out = 0;
|
||||||
while (*str == " ")
|
while (*str == ' ')
|
||||||
str++;
|
str++;
|
||||||
sign = 1;
|
sign = 1;
|
||||||
if (*str == '-')
|
if (*str == '-')
|
||||||
@ -30,7 +31,7 @@ int ft_atoi(const char *nptr)
|
|||||||
while (ft_isdigit(*str))
|
while (ft_isdigit(*str))
|
||||||
{
|
{
|
||||||
out = 10 * out + *str - 48;
|
out = 10 * out + *str - 48;
|
||||||
*str++;
|
str++;
|
||||||
}
|
}
|
||||||
return (out * sign)
|
return (out * sign);
|
||||||
}
|
}
|
||||||
|
26
ft_memccpy.c
Normal file
26
ft_memccpy.c
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_memccpy.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2022/09/27 16:53:36 by cchauvet #+# #+# */
|
||||||
|
/* Updated: 2022/09/27 17:21:51 by cchauvet ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
void *memccpy(void *dest, const void *src, int c, size_t n)
|
||||||
|
{
|
||||||
|
int *tab;
|
||||||
|
size_t max;
|
||||||
|
|
||||||
|
tab = (int *) src;
|
||||||
|
while (max < ft_strlen((char *) tab) && tab[max] == c)
|
||||||
|
max++;
|
||||||
|
if (max < n)
|
||||||
|
max = n;
|
||||||
|
return (ft_memcpy(dest, src, max));
|
||||||
|
}
|
34
ft_strlcat.c
Normal file
34
ft_strlcat.c
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_strlcat.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2022/09/27 17:02:13 by cchauvet #+# #+# */
|
||||||
|
/* Updated: 2022/09/27 17:23:07 by cchauvet ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
char *strlcat(char *dst, const char *src, size_t size)
|
||||||
|
{
|
||||||
|
size_t max;
|
||||||
|
char *str;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
str = (char *) src;
|
||||||
|
max = size;
|
||||||
|
if (ft_strlen(str) > max)
|
||||||
|
max = ft_strlen(str);
|
||||||
|
if (ft_strlen(dst) > max)
|
||||||
|
max = ft_strlen(dst);
|
||||||
|
i = 0;
|
||||||
|
while (i < max)
|
||||||
|
{
|
||||||
|
dst[i] = str[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (dst);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user