-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strrjoin.c
41 lines (38 loc) · 1.27 KB
/
ft_strrjoin.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: plisieck <plisieck@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/02/04 14:49:15 by plisieck #+# #+# */
/* Updated: 2015/02/08 17:42:00 by plisieck ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
char *ft_strrjoin(char *s1, char *s2, int pos)
{
int i;
int j;
char *str;
int cut;
str = (char *)malloc(sizeof(int) * ft_strlen(s1) + ft_strlen(s2) + 1);
i = 0;
j = 0;
while (i < pos)
{
str[i] = s1[i];
i++;
}
cut = i;
while (s2[j] != '\0')
{
str[i] = s2[j];
i++;
j++;
}
while (s1[cut] != '\0')
str[i++] = s1[cut++];
str[i] = '\0';
return (str);
}