-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_cpytab.c
executable file
·52 lines (47 loc) · 1.46 KB
/
ft_cpytab.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
42
43
44
45
46
47
48
49
50
51
52
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_cpytab.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbenjami <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/05/30 17:20:00 by rbenjami #+# #+# */
/* Updated: 2015/05/22 10:32:43 by rbenjami ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char **ft_cpytab(char **tab, int lenth)
{
char **new_tab;
int i;
int tablen;
i = 0;
tablen = ft_tabsize((void **)tab);
new_tab = (char **)ft_memalloc(sizeof(char *) * lenth + 1);
while (i < tablen)
{
new_tab[i] = ft_strdup(tab[i]);
i++;
}
return (new_tab);
}
int **ft_cpytab_int(int **tab, int x, int y)
{
int **new_tab;
int i;
int j;
i = 0;
new_tab = (int **)ft_memalloc(sizeof(int *) * x);
while (i < x)
{
j = 0;
new_tab[i] = ft_memalloc(sizeof(int) * y);
while (j < y)
{
new_tab[i][j] = tab[i][j];
j++;
}
i++;
}
return (new_tab);
}