From 385904df494f7f28921917072d020ee6a93cf8bf Mon Sep 17 00:00:00 2001 From: Timo Schmidt Date: Tue, 28 Mar 2023 02:50:02 +0200 Subject: [PATCH] ex00 --- ex04/ft_strstr.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++ ex05/ft_strlcat.c | 7 ++++--- 2 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 ex04/ft_strstr.c diff --git a/ex04/ft_strstr.c b/ex04/ft_strstr.c new file mode 100644 index 0000000..6124123 --- /dev/null +++ b/ex04/ft_strstr.c @@ -0,0 +1,50 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strstr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: tischmid +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/03/24 02:23:28 by tischmid #+# #+# */ +/* Updated: 2023/03/24 03:18:35 by tischmid ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +char *ft_strstr(char *str, char *to_find) +{ + int offset; + char *orig_to_find; + + orig_to_find = to_find; + while (*str) + { + offset = 0; + while (*(to_find + offset)) + { + if (*(to_find + offset) != *(str + offset)) + break ; + ++offset; + } + if (!*(to_find + offset)) + return (str); + to_find = orig_to_find; + ++str; + } + return ((void *) 0); +} + +/* //// +#include +#define STR1 "hello" +#define STR2 "aa" + +int main(void) +{ + printf("String to search in: %s\n", STR1); + printf("String to find: %s\n", STR2); + printf("Result: %s\n", ft_strstr(STR1, STR2)); + return (0); +} +*/ //// diff --git a/ex05/ft_strlcat.c b/ex05/ft_strlcat.c index 95aaf3b..4c33e11 100644 --- a/ex05/ft_strlcat.c +++ b/ex05/ft_strlcat.c @@ -6,11 +6,12 @@ /* By: tischmid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/03/24 03:19:16 by tischmid #+# #+# */ -/* Updated: 2023/03/27 00:48:27 by tischmid ### ########.fr */ +/* Updated: 2023/03/28 02:49:49 by tischmid ### ########.fr */ /* */ /* ************************************************************************** */ #include + unsigned int ft_strlcat(char *dest, char *src, unsigned int size) { int src_len; @@ -29,10 +30,9 @@ unsigned int ft_strlcat(char *dest, char *src, unsigned int size) while (*o_src++) ++src_len; return (src_len); - } -#define START +/* //// #include int main(void) @@ -43,3 +43,4 @@ int main(void) printf("%s\n", s); return (0); } +*/ ////