-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strdup.c
34 lines (31 loc) · 1.16 KB
/
ft_strdup.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sgrindhe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/07/12 04:38:12 by sgrindhe #+# #+# */
/* Updated: 2018/08/05 23:17:37 by sgrindhe ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(char *src)
{
int i;
int counter;
char *strcp;
i = 0;
while (src[i] != '\0')
{
i++;
}
strcp = (char*)malloc((sizeof(char) * (i + 1)));
counter = 0;
while (strcp && counter <= i)
{
strcp[counter] = src[counter];
counter++;
}
return (strcp);
}