-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strjoin.c
More file actions
56 lines (53 loc) · 1.51 KB
/
Copy pathft_strjoin.c
File metadata and controls
56 lines (53 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dpadenko <dpadenko@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/11 17:57:16 by dpadenko #+# #+# */
/* Updated: 2023/09/15 22:27:32 by dpadenko ### ########.fr */
/* */
/* ************************************************************************** */
//#include <stdio.h>
//#include <stdlib.h>
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
char *str;
int i;
int j;
i = 0;
j = 0;
str = malloc(ft_strlen((char *)s1) + ft_strlen((char *)s2) + 1);
if (str == NULL)
return (NULL);
while (s1[j] != '\0')
{
str[i] = s1[j];
i++;
j++;
}
j = 0;
while (s2[j] != '\0')
{
str[i] = s2[j];
i++;
j++;
}
str[i] = '\0';
return (str);
}
/*
int main(void)
{
char a[] = "I'm the first string...";
char b[] = "and I'm the second";
char *joinstr = ft_strjoin(a, b);
if (joinstr != NULL)
{
printf("%s\n", joinstr);
free(joinstr);
}
}
*/