aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libft/Makefile1
-rw-r--r--lib/libft/ft_memset.c14
-rw-r--r--lib/libft/ft_strncpy.c21
-rw-r--r--lib/libft/libft.h5
4 files changed, 37 insertions, 4 deletions
diff --git a/lib/libft/Makefile b/lib/libft/Makefile
index 3c2fb91..6951c43 100644
--- a/lib/libft/Makefile
+++ b/lib/libft/Makefile
@@ -30,6 +30,7 @@ SRC = ft_atoi.c \
ft_strlen.c \
ft_strmapi.c \
ft_strncmp.c \
+ ft_strncpy.c \
ft_strnstr.c \
ft_strrchr.c \
ft_strtrim.c \
diff --git a/lib/libft/ft_memset.c b/lib/libft/ft_memset.c
index 58c5e1e..085df1d 100644
--- a/lib/libft/ft_memset.c
+++ b/lib/libft/ft_memset.c
@@ -3,10 +3,10 @@
/* ::: :::::::: */
/* ft_memset.c :+: :+: :+: */
/* +:+ +:+ +:+ */
-/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
+/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/05 09:58:19 by dkaiser #+# #+# */
-/* Updated: 2024/03/10 13:13:09 by dkaiser ### ########.fr */
+/* Updated: 2024/07/11 23:52:13 by chuhlig ### ########.fr */
/* */
/* ************************************************************************** */
@@ -35,3 +35,13 @@ void *ft_memset(void *b, int c, size_t len)
/* printf("ft_memset: %s\n", ft_memset((char *)str, 'A' + 255, 5)); */
/* printf("memset: %s\n", memset((char *)str, 'A' + 255, 5)); */
/* } */
+
+// void *ft_memset(void *b, int c, size_t len)
+// {
+// void *savearg;
+
+// savearg = b;
+// while (len--)
+// *(unsigned char *)b++ = (unsigned char)c;
+// return (savearg);
+// } \ No newline at end of file
diff --git a/lib/libft/ft_strncpy.c b/lib/libft/ft_strncpy.c
new file mode 100644
index 0000000..a1a2293
--- /dev/null
+++ b/lib/libft/ft_strncpy.c
@@ -0,0 +1,21 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_strncpy.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2024/08/05 13:41:47 by chuhlig #+# #+# */
+/* Updated: 2024/08/09 15:26:40 by chuhlig ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+char *ft_strncpy(char *s1, char *s2, int n)
+{
+ int i;
+
+ i = -1;
+ while (++i < n && s2[i])
+ s1[i] = s2[i];
+ return (s1);
+}
diff --git a/lib/libft/libft.h b/lib/libft/libft.h
index 2de723b..67fbb0f 100644
--- a/lib/libft/libft.h
+++ b/lib/libft/libft.h
@@ -3,10 +3,10 @@
/* ::: :::::::: */
/* libft.h :+: :+: :+: */
/* +:+ +:+ +:+ */
-/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
+/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/10 16:37:54 by dkaiser #+# #+# */
-/* Updated: 2024/06/24 16:44:44 by dkaiser ### ########.fr */
+/* Updated: 2024/08/05 13:55:13 by chuhlig ### ########.fr */
/* */
/* ************************************************************************** */
@@ -57,6 +57,7 @@ void ft_putchar_fd(char c, int fd);
void ft_putstr_fd(char *s, int fd);
void ft_putendl_fd(char *s, int fd);
void ft_putnbr_fd(int n, int fd);
+char *ft_strncpy(char *s1, char *s2, int n);
typedef struct s_list
{