]> git.dkaiser.de - 42/libft.git/commitdiff
Setup and current progress
authorDominik Kaiser <dkaiser@1-C-13.42heilbronn.de>
Wed, 6 Mar 2024 20:02:09 +0000 (21:02 +0100)
committerDominik Kaiser <dkaiser@1-C-13.42heilbronn.de>
Wed, 6 Mar 2024 20:02:09 +0000 (21:02 +0100)
Forgot to commit earlier...

28 files changed:
Makefile [new file with mode: 0644]
ft_atoi.c [new file with mode: 0644]
ft_bzero.c [new file with mode: 0644]
ft_calloc.c [new file with mode: 0644]
ft_isalnum.c [new file with mode: 0644]
ft_isalpha.c [new file with mode: 0644]
ft_isascii.c [new file with mode: 0644]
ft_isdigit.c [new file with mode: 0644]
ft_isprint.c [new file with mode: 0644]
ft_memchr.c [new file with mode: 0644]
ft_memcmp.c [new file with mode: 0644]
ft_memcpy.c [new file with mode: 0644]
ft_memmove.c [new file with mode: 0644]
ft_memset.c [new file with mode: 0644]
ft_putchar_fd.c [new file with mode: 0644]
ft_putendl_fd.c [new file with mode: 0644]
ft_putstr_fd.c [new file with mode: 0644]
ft_strchr.c [new file with mode: 0644]
ft_strdup.c [new file with mode: 0644]
ft_strlcat.c [new file with mode: 0644]
ft_strlcpy.c [new file with mode: 0644]
ft_strlen.c [new file with mode: 0644]
ft_strncmp.c [new file with mode: 0644]
ft_strnstr.c [new file with mode: 0644]
ft_strrchr.c [new file with mode: 0644]
ft_tolower.c [new file with mode: 0644]
ft_toupper.c [new file with mode: 0644]
libft.h [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/ft_atoi.c b/ft_atoi.c
new file mode 100644 (file)
index 0000000..6f7bd55
--- /dev/null
+++ b/ft_atoi.c
@@ -0,0 +1,45 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_atoi.c                                          :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/06 16:25:27 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/06 19:41:51 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+int    ft_atoi(const char *str)
+{
+       int     result;
+       int     i;
+       int     posneg;
+
+       posneg = 1;
+       result = 0;
+       i = 0;
+       while (str[i] >= '\t' && str[i] <= '\r' || str[i] == ' ')
+       {
+               i++;
+       }
+       if (str[i] == '-')
+       {
+               posneg = -1;
+               i++;
+       }
+       while (str[i] >= '0' && str[i] <= '9')
+       {
+               result = 10 * result + str[i] - '0';
+               i++;
+       }
+       return (result * posneg);
+}
+
+/* #include <stdio.h> */
+/* #include <stdlib.h> */
+/* int main() { */
+/*     char str[] = "         -42eaeouai"; */
+/*     printf("atoi: %d\n", atoi(str)); */
+/*     printf("ft_atoi: %d\n", ft_atoi(str)); */
+/* } */
diff --git a/ft_bzero.c b/ft_bzero.c
new file mode 100644 (file)
index 0000000..d84d507
--- /dev/null
@@ -0,0 +1,27 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_bzero.c                                         :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/05 10:57:36 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/06 11:49:38 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <string.h>
+
+void   ft_bzero(void *s, size_t n)
+{
+       char    *ptr;
+       size_t  i;
+
+       ptr = (char *)b;
+       i = 0;
+       while (i < n)
+       {
+               ptr[i] = 0;
+               i++;
+       }
+}
diff --git a/ft_calloc.c b/ft_calloc.c
new file mode 100644 (file)
index 0000000..117892d
--- /dev/null
@@ -0,0 +1,28 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_calloc.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/06 19:45:56 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/06 19:52:19 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <stdlib.h>
+
+void   *calloc(size_t count, size_t size)
+{
+       void    *result;
+       size_t  i;
+
+       result = malloc(count * size);
+       i = 0;
+       while (i < count * size)
+       {
+               *((char *)result + i) = 0;
+               i++;
+       }
+       return (result);
+}
diff --git a/ft_isalnum.c b/ft_isalnum.c
new file mode 100644 (file)
index 0000000..4de4a63
--- /dev/null
@@ -0,0 +1,19 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_isalnum.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/04 21:14:49 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/04 21:17:16 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+int    ft_isalnum(int c)
+{
+       if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0'
+                       && c <= '9'))
+               return (1);
+       return (0);
+}
diff --git a/ft_isalpha.c b/ft_isalpha.c
new file mode 100644 (file)
index 0000000..667bb5f
--- /dev/null
@@ -0,0 +1,18 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_isalpha.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/04 19:59:23 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/04 21:06:31 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+int    isalpha(int c)
+{
+       if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
+               return (1);
+       return (0);
+}
diff --git a/ft_isascii.c b/ft_isascii.c
new file mode 100644 (file)
index 0000000..6570d44
--- /dev/null
@@ -0,0 +1,18 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_isascii.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/04 21:23:25 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/04 21:24:46 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+int    ft_isascii(int c)
+{
+       if (c >= 0 && c < 128)
+               return (1);
+       return (0);
+}
diff --git a/ft_isdigit.c b/ft_isdigit.c
new file mode 100644 (file)
index 0000000..273bfa3
--- /dev/null
@@ -0,0 +1,18 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_isdigit.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/04 21:07:03 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/04 21:18:00 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+int    ft_isdigit(int c)
+{
+       if (c >= '0' && c <= '9')
+               return (1);
+       return (0);
+}
diff --git a/ft_isprint.c b/ft_isprint.c
new file mode 100644 (file)
index 0000000..6c9faed
--- /dev/null
@@ -0,0 +1,18 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_isprint.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/04 21:25:31 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/04 21:27:57 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+int    ft_isprint(int c)
+{
+       if (c >= ' ' && c <= '~')
+               return (1);
+       return (0);
+}
diff --git a/ft_memchr.c b/ft_memchr.c
new file mode 100644 (file)
index 0000000..da3b0a6
--- /dev/null
@@ -0,0 +1,34 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_memchr.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/06 15:23:01 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/06 15:50:06 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <string.h>
+
+void   *ft_memchr(const void *s, int c, size_t n)
+{
+       size_t  i;
+
+       i = 0;
+       while (i < n)
+       {
+               if (*((unsigned char *)s + i) == (unsigned char)c)
+                       return ((void *)s + i);
+               i++;
+       }
+       return (0);
+}
+
+/* #include <stdio.h> */
+/* int main () { */
+/*     char str[] = "Hello world"; */
+/*     printf("memchr: %s\n", (char *) memchr(str, 'o', 11)); */
+/*     printf("ft_memchr: %s\n", (char *) ft_memchr(str, 'o', 11)); */
+/* } */
diff --git a/ft_memcmp.c b/ft_memcmp.c
new file mode 100644 (file)
index 0000000..a1e18da
--- /dev/null
@@ -0,0 +1,39 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_memcmp.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/06 15:54:13 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/06 19:45:09 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <string.h>
+
+int    ft_memcmp(const void *s1, const void *s2, size_t n)
+{
+       size_t  i;
+       int             result;
+
+       i = 0;
+       result = 0;
+       while (!result && i < n)
+       {
+               result = *((unsigned char *)s1 + i) - *((unsigned char *)s2 + i);
+               i++;
+       }
+       return (result);
+}
+
+/* #include <stdio.h> */
+
+/* int main(void) */
+/* { */
+/*     char    str1[] = "Hello"; */
+/*     char    str2[] = "Hellu"; */
+
+/*     printf("memcmp: %d\n", memcmp(str1, str2, 5)); */
+/*     printf("ft_memcmp: %d\n", ft_memcmp(str1, str2, 5)); */
+/* } */
diff --git a/ft_memcpy.c b/ft_memcpy.c
new file mode 100644 (file)
index 0000000..49c4575
--- /dev/null
@@ -0,0 +1,37 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_memcpy.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/05 11:15:12 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/05 11:39:34 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <string.h>
+
+void   *ft_memcpy(void *restrict dst, const void *restrict src, size_t n)
+{
+       size_t  i;
+
+       i = 0;
+       while (i < n)
+       {
+               *((char *)dst + i) = *((char *)src + i);
+               i++;
+       }
+       return (dst);
+}
+
+/* #include <stdio.h> */
+/* int main(void) */
+/* { */
+/*     char src[] = "Test Hurra"; */
+/*     char src2[] = "Test Hurra"; */
+/*     char dst[] = "AAAAAAIIIIIEEEEE"; */
+/*     char dst2[] = "AAAAAAIIIIIEEEEE"; */
+/*     printf("ft_memcpy: %s\n", (char *) ft_memcpy(dst, src, 20)); */
+/*     printf("memcpy: %s\n", (char *) memcpy(dst2, src2, 20)); */
+/* } */
diff --git a/ft_memmove.c b/ft_memmove.c
new file mode 100644 (file)
index 0000000..9ca3fac
--- /dev/null
@@ -0,0 +1,48 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_memmove.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/05 11:41:44 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/06 14:12:14 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <string.h>
+
+void   *ft_memmove(void *dst, const void *src, size_t len)
+{
+       size_t  i;
+
+       if (dst > src)
+       {
+               i = len;
+               while (i-- > 0)
+               {
+                       *((char *)dst + i) = *((char *)src + i);
+               }
+       }
+       else
+       {
+               i = 0;
+               while (i < len)
+               {
+                       *((char *)dst + i) = *((char *)src + i);
+                       i++;
+               }
+       }
+       return (dst);
+}
+
+/* #include <stdio.h> */
+
+/* int main(void) */
+/* { */
+/*     char    text[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; */
+/*     char    text2[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; */
+
+/*     printf("memmove: %s\n", memmove(text + 5, text, 5)); */
+/*     printf("ft_memmove: %s\n", ft_memmove(text2 + 5, text2, 5)); */
+/* } */
diff --git a/ft_memset.c b/ft_memset.c
new file mode 100644 (file)
index 0000000..618a78d
--- /dev/null
@@ -0,0 +1,39 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_memset.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/05 09:58:19 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/05 11:21:24 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <string.h>
+
+void   *ft_memset(void *b, int c, size_t len)
+{
+       char    *ptr;
+       size_t  i;
+
+       ptr = (char *)b;
+       i = 0;
+       while (i < len)
+       {
+               ptr[i] = (unsigned char)c;
+               i++;
+       }
+       return (b);
+}
+
+/* #include <stdio.h> */
+
+/* int main(void) */
+/* { */
+/*     char    str[] = "Hello world"; */
+
+/*     printf("STR: %s\n", str); */
+/*     printf("ft_memset: %s\n", ft_memset((char *)str, 'A' + 255, 5)); */
+/*     printf("memset: %s\n", memset((char *)str, 'A' + 255, 5)); */
+/* } */
diff --git a/ft_putchar_fd.c b/ft_putchar_fd.c
new file mode 100644 (file)
index 0000000..1eca491
--- /dev/null
@@ -0,0 +1,18 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_putchar_fd.c                                    :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/06 20:36:14 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/06 20:38:06 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <unistd.h>
+
+void   ft_putchar_fd(char c, int fd)
+{
+    write(fd, &c, 1);
+}
diff --git a/ft_putendl_fd.c b/ft_putendl_fd.c
new file mode 100644 (file)
index 0000000..9929875
--- /dev/null
@@ -0,0 +1,26 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_putendl_fd.c                                    :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/06 20:47:17 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/06 20:49:12 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <unistd.h>
+
+void   ft_putendl_fd(char *s, int fd)
+{
+       int     len;
+
+       len = 0;
+       while (s[len])
+       {
+               len++;
+       }
+       write(fd, s, len);
+       write(fd, "\n", 1);
+}
diff --git a/ft_putstr_fd.c b/ft_putstr_fd.c
new file mode 100644 (file)
index 0000000..3be5a70
--- /dev/null
@@ -0,0 +1,23 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_putstr_fd.c                                     :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/06 20:43:05 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/06 20:45:40 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <unistd.h>
+
+void   ft_putstr_fd(char *s, int fd)
+{
+       int     len;
+
+       len = 0;
+       while (s[len])
+               len++;
+       write(fd, s, len);
+}
diff --git a/ft_strchr.c b/ft_strchr.c
new file mode 100644 (file)
index 0000000..e53f78e
--- /dev/null
@@ -0,0 +1,33 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strchr.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/06 14:12:39 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/06 14:35:37 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+char   *ft_strchr(const char *s, int c)
+{
+       int     i;
+
+       i = 0;
+       while (s[i] != '\0')
+       {
+               if (s[i] == (char)c)
+                       return ((char *)&s[i]);
+               i++;
+       }
+       return (0);
+}
+
+/* #include <stdio.h> */
+/* #include <string.h> */
+/* int main() { */
+/*     char str[] = "Hello world"; */
+/*     printf("strchr: %s\n", strchr(str, 'o')); */
+/*     printf("ft_strchr: %s\n", ft_strchr(str, 'o')); */
+/* } */
diff --git a/ft_strdup.c b/ft_strdup.c
new file mode 100644 (file)
index 0000000..af7ab12
--- /dev/null
@@ -0,0 +1,38 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strdup.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/06 19:54:16 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/06 20:24:51 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <stdlib.h>
+
+char   *ft_strdup(const char *s1)
+{
+       char    *result;
+       int             len;
+
+       len = 0;
+       while (*(s1++))
+               len++;
+       result = malloc(len + 1);
+       if (!result)
+               return (0);
+       result[++len] = '\0';
+       while (len--)
+               result[len] = *(--s1);
+       return (result);
+}
+
+/* #include <stdio.h> */
+/* int main() { */
+/*     char *output; */
+/*     char input[] = "Dies ist ein Test."; */
+/*     output = ft_strdup(input); */
+/*     printf("%s\n", output); */
+/* } */
diff --git a/ft_strlcat.c b/ft_strlcat.c
new file mode 100644 (file)
index 0000000..c16105a
--- /dev/null
@@ -0,0 +1,48 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strlcat.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/06 13:36:59 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/06 14:11:36 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <string.h>
+
+size_t ft_strlcat(char *restrict dst, const char *restrict src, size_t dstsize)
+{
+       size_t  len;
+       size_t  i;
+
+       if (dstsize == 0)
+               return (0);
+       len = 0;
+       while (len < dstsize - 1 && dst[len] != '\0')
+       {
+               len++;
+       }
+       i = 0;
+       while (len < dstsize - 1 && src[i] != '\0')
+       {
+               dst[len] = src[i];
+               len++;
+               i++;
+       }
+       dst[len] = '\0';
+       return (len);
+}
+
+/* #include <stdio.h> */
+/* int main () { */
+/*     char dst[12] = "Hello "; */
+/*     char dst2[12] = "Hello "; */
+/*     char src[] = "World"; */
+
+/*     size_t len = strlcat(dst, src, 12); */
+/*     size_t len2 = ft_strlcat(dst2, src, 12); */
+/*     printf("strlcat (%zu): %s\n", len, dst); */
+/*     printf("ft_strlcat (%zu): %s\n", len2, dst2); */
+/* } */
diff --git a/ft_strlcpy.c b/ft_strlcpy.c
new file mode 100644 (file)
index 0000000..670bf18
--- /dev/null
@@ -0,0 +1,50 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strlcpy.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/06 12:45:25 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/06 13:30:25 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <string.h>
+
+size_t ft_strlcpy(char *restrict dst, const char *restrict src, size_t dstsize)
+{
+       size_t  len;
+
+       len = 0;
+       if (dstsize > 0)
+       {
+               while (len < dstsize - 1 && src[len] != '\0')
+               {
+                       dst[len] = src[len];
+                       len++;
+               }
+               dst[len] = '\0';
+               while (src[len] != '\0')
+               {
+                       len++;
+               }
+       }
+       return (len);
+}
+
+/* #include <stdio.h> */
+
+/* int main(void) */
+/* { */
+/*     char    src[] = "Hello"; */
+/*     char    dst[] = "01234567890123456789"; */
+/*     char    dst2[] = "01234567890123456789"; */
+/*     size_t  len; */
+/*     size_t  len2; */
+
+/*     len = strlcpy(dst, src, 10); */
+/*     len2 = ft_strlcpy(dst2, src, 10); */
+/*     printf("strlcpy (%zu): %s\n", len, dst); */
+/*     printf("ft_strlcpy (%zu): %s\n", len2, dst2); */
+/* } */
diff --git a/ft_strlen.c b/ft_strlen.c
new file mode 100644 (file)
index 0000000..e201765
--- /dev/null
@@ -0,0 +1,21 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strlen.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/04 21:29:35 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/04 21:31:24 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+int    ft_strlen(const char *str)
+{
+       int     len;
+
+       len = 0;
+       while (str[len])
+               len++;
+       return (len);
+}
diff --git a/ft_strncmp.c b/ft_strncmp.c
new file mode 100644 (file)
index 0000000..2d54ec5
--- /dev/null
@@ -0,0 +1,38 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strncmp.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/06 14:45:10 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/06 15:10:48 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <string.h>
+
+int    ft_strncmp(const char *s1, const char *s2, size_t n)
+{
+       int     result;
+
+       result = 0;
+       while (!result && n > 0 && (*s1 || *s2))
+       {
+               result = *s1 - *s2;
+               if (*s1)
+                       s1++;
+               if (*s2)
+                       s2++;
+               n--;
+       }
+       return (result);
+}
+
+/* #include <stdio.h> */
+/* int main() { */
+/*     char str1[] = "Hello"; */
+/*     char str2[] = "Hellu"; */
+/*     printf("strncmp: %d\n", strncmp(str1, str2, 5)); */
+/*     printf("ft_strncmp: %d\n", ft_strncmp(str1, str2, 5)); */
+/* } */
diff --git a/ft_strnstr.c b/ft_strnstr.c
new file mode 100644 (file)
index 0000000..b91d162
--- /dev/null
@@ -0,0 +1,41 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strnstr.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/06 16:07:54 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/06 16:24:52 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include <string.h>
+
+char   *ft_strnstr(const char *haystack, const char *needle, size_t len)
+{
+       size_t  i;
+       size_t  k;
+
+       i = 0;
+       while (i < len)
+       {
+               k = 0;
+               while (haystack[i + k] == needle[k])
+               {
+                       k++;
+               }
+               if (!needle[k])
+                       return ((char *)haystack + i);
+               i++;
+       }
+       return (0);
+}
+
+/* #include <stdio.h> */
+/* int main() { */
+/*     char haystack[] = "Hello world"; */
+/*     char needle[] = "d"; */
+/*     printf("strnstr: %s\n", strnstr(haystack, needle, 10)); */
+/*     printf("ft_strnstr: %s\n", ft_strnstr(haystack, needle, 10)); */
+/* } */
diff --git a/ft_strrchr.c b/ft_strrchr.c
new file mode 100644 (file)
index 0000000..e548f5b
--- /dev/null
@@ -0,0 +1,38 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_strrchr.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/06 14:25:30 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/06 14:35:16 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+char   *ft_strrchr(const char *s, int c)
+{
+       int             i;
+       char    *last_occurrence;
+
+       last_occurrence = 0;
+       i = 0;
+       while (s[i] != '\0')
+       {
+               if (s[i] == (char)c)
+                       last_occurrence = (char *)&s[i];
+               i++;
+       }
+       return (last_occurrence);
+}
+
+/* #include <stdio.h> */
+/* #include <string.h> */
+
+/* int main(void) */
+/* { */
+/*     char    str[] = "Hello world"; */
+
+/*     printf("strrchr: %s\n", strrchr(str, 'o')); */
+/*     printf("ft_strrchr: %s\n", ft_strrchr(str, 'o')); */
+/* } */
diff --git a/ft_tolower.c b/ft_tolower.c
new file mode 100644 (file)
index 0000000..31e848f
--- /dev/null
@@ -0,0 +1,18 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_tolower.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/04 21:49:28 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/06 11:49:49 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+int    ft_tolower(int c)
+{
+       if (c >= 'A' && c <= 'Z')
+               return (c + 32);
+       return (c);
+}
diff --git a/ft_toupper.c b/ft_toupper.c
new file mode 100644 (file)
index 0000000..5082232
--- /dev/null
@@ -0,0 +1,18 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_toupper.c                                       :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2024/03/04 21:33:34 by dkaiser           #+#    #+#             */
+/*   Updated: 2024/03/04 21:49:16 by dkaiser          ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+int    ft_toupper(int c)
+{
+       if (c >= 'a' && c <= 'z')
+               return (c - 32);
+       return (c);
+}
diff --git a/libft.h b/libft.h
new file mode 100644 (file)
index 0000000..dbad3f8
--- /dev/null
+++ b/libft.h
@@ -0,0 +1,6 @@
+#ifndef LIBFT_H_
+#define LIBFT_H_
+
+
+
+#endif // LIBFT_H_