-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strdup.c
31 lines (28 loc) · 1.13 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maareval <maareval@student.42malaga.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/01 08:07:56 by maareval #+# #+# */
/* Updated: 2022/05/01 08:14:45 by maareval ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *str)
{
int i;
char *dest;
dest = (char *) malloc (sizeof(char) * (ft_strlen(str) + 1));
i = 0;
if (!dest)
return (NULL);
while (str[i])
{
dest[i] = str[i];
i++;
}
dest[i] = '\0';
return (dest);
}