-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strdup.c
28 lines (25 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sahafid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/07 12:14:48 by sahafid #+# #+# */
/* Updated: 2021/11/07 12:17:13 by sahafid ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *src)
{
int src_len;
char *dest;
char *a;
src_len = ft_strlen(src);
a = (char *)src;
dest = (char *)malloc(src_len + 1 * sizeof(char));
if (dest == NULL)
return (NULL);
ft_strcpy(dest, a);
return (dest);
}