-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_strdup.c
28 lines (25 loc) · 1.11 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rde-noro <rde-noro@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/24 20:03:47 by rde-noro #+# #+# */
/* Updated: 2022/09/27 23:41:46 by rde-noro ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *src)
{
char *result;
int i;
result = (char *)malloc(ft_strlen(src) + 1);
if (!result)
return (NULL);
i = 0;
while (*src)
result[i++] = *src++;
result[i] = '\0';
return (result);
}