-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strdup.c
More file actions
34 lines (31 loc) · 1.12 KB
/
Copy pathft_strdup.c
File metadata and controls
34 lines (31 loc) · 1.12 KB
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: vbraeke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/27 14:20:52 by vbraeke #+# #+# */
/* Updated: 2015/12/21 14:58:10 by vbraeke ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(char *str)
{
int i;
char *dup;
i = 0;
dup = (char *)malloc(ft_strlen(str) + 1);
if (dup == NULL)
return (NULL);
else
{
while (str[i])
{
dup[i] = str[i];
i++;
}
dup[i] = '\0';
return (dup);
}
}