From f91dafa6bb756fa4ee85b7b55ffd6a4ac2e2dc52 Mon Sep 17 00:00:00 2001 From: Timo Schmidt Date: Fri, 24 Mar 2023 02:20:45 +0100 Subject: [PATCH] ex03 --- ex03/ft_strncat.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 ex03/ft_strncat.c diff --git a/ex03/ft_strncat.c b/ex03/ft_strncat.c new file mode 100644 index 0000000..bd26ece --- /dev/null +++ b/ex03/ft_strncat.c @@ -0,0 +1,42 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strncat.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: tischmid +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/03/24 02:14:28 by tischmid #+# #+# */ +/* Updated: 2023/03/24 02:20:08 by tischmid ### ########.fr */ +/* */ +/* ************************************************************************** */ + +char *ft_strncat(char *dest, char *src, unsigned int nb) +{ + char *orig_dest; + + orig_dest = dest; + while (*dest) + ++dest; + while (*src && nb--) + *dest++ = *src++; + *dest = 0; + return (orig_dest); +} + +/* //// +#include +#define STR1 "0123" +#define STR2 "abc" +#define LENGTH 2 + +int main(void) +{ + char s1[] = STR1; + char s2[] = STR2; + printf("Length: %d\n", LENGTH); + printf("s1: %s s2: %s\n", s1, s2); + ft_strncat(s1, s2, LENGTH); + printf("s1: %s s2: %s\n", s1, s2); + return (0); +} +*/ ////