-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strdup.c
33 lines (30 loc) · 1.2 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: malexand <malexand@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/07/16 10:51:55 by malexand #+# #+# */
/* Updated: 2017/09/26 18:12:07 by malexand ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *src)
{
int count;
int src_size;
char *new_str;
count = 0;
src_size = ft_strlen(src);
new_str = ft_strnew(src_size);
if (new_str == NULL)
return (NULL);
while (count < src_size)
{
new_str[count] = src[count];
count++;
}
new_str[src_size] = '\0';
return (new_str);
}