-
Notifications
You must be signed in to change notification settings - Fork 0
/
mallocat.c
executable file
·37 lines (34 loc) · 1.23 KB
/
mallocat.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mallocat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sdurr <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/08/18 17:17:05 by sdurr #+# #+# */
/* Updated: 2014/08/18 19:02:48 by sdurr ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft.h"
#include <stdlib.h>
#include <stdio.h>
char *ft_mallocat(char *str, char *buf)
{
int i;
int j;
char *tmp;
i = -1;
j = 0;
tmp = (char *)malloc(sizeof(char) * 1000);
if (tmp == NULL)
return (0);
while (str[++i])
tmp[j++] = str[i];
i = -1;
while (buf[++i])
tmp[j++] = buf[i];
tmp[j] = '\0';
free(str);
free(buf);
return (tmp);
}