aboutsummaryrefslogtreecommitdiff
path: root/lib/libft/ft_strjoin.c
diff options
context:
space:
mode:
authorChristopher Uhlig2025-01-22 02:40:27 +0100
committerChristopher Uhlig2025-01-22 02:40:27 +0100
commitf6e474d27a1398c6d4f2e88c7f2d3797b85217da (patch)
tree7dd7bd5f2a151b39498991b567ae51cff8242782 /lib/libft/ft_strjoin.c
parent78dc50a2bce3c6e31405437189e2990d8fc720ac (diff)
downloadminishell-f6e474d27a1398c6d4f2e88c7f2d3797b85217da.tar.gz
minishell-f6e474d27a1398c6d4f2e88c7f2d3797b85217da.zip
kinda fix for pipe error and again.vs for you db just chnage workfolder gn
Diffstat (limited to 'lib/libft/ft_strjoin.c')
-rw-r--r--lib/libft/ft_strjoin.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/lib/libft/ft_strjoin.c b/lib/libft/ft_strjoin.c
index 526592b..5c0bf41 100644
--- a/lib/libft/ft_strjoin.c
+++ b/lib/libft/ft_strjoin.c
@@ -3,44 +3,44 @@
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
-/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
+/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/07 10:15:33 by dkaiser #+# #+# */
-/* Updated: 2024/03/10 14:02:07 by dkaiser ### ########.fr */
+/* Updated: 2025/01/22 00:27:04 by chuhlig ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
-static int copy_str(char *dst, const char *src)
-{
- int i;
-
- i = 0;
- while (src[i])
- {
- dst[i] = src[i];
- i++;
- }
- return (i);
-}
+// static int copy_str(char *dst, const char *src)
+// {
+// int i;
+
+// i = 0;
+// while (src[i])
+// {
+// dst[i] = src[i];
+// i++;
+// }
+// return (i);
+// }
-char *ft_strjoin(char const *s1, char const *s2)
+char *ft_strjoin(const char *s1, const char *s2)
{
- int len;
- char *result;
-
- len = ft_strlen(s1) + ft_strlen(s2);
- result = malloc(len + 1);
- if (result)
- {
- result[len] = '\0';
- len = copy_str(result, s1);
- len = copy_str(result + len, s2);
- return (result);
- }
- else
- return (0);
+ char *joined_str;
+ size_t len1;
+ size_t len2;
+
+ if (!s1 || !s2)
+ return (NULL);
+ len1 = strlen(s1);
+ len2 = strlen(s2);
+ joined_str = malloc(len1 + len2 + 1);
+ if (!joined_str)
+ return (NULL);
+ strcpy(joined_str, s1);
+ strcat(joined_str, s2);
+ return (joined_str);
}
/* #include <stdio.h> */