-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strdup.c
27 lines (24 loc) · 1.1 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zbenaiss <zbenaiss@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/24 21:12:04 by zbenaiss #+# #+# */
/* Updated: 2022/10/26 03:50:13 by zbenaiss ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s1)
{
int i;
char *str;
i = 0;
str = (char *)malloc(ft_strlen(s1) + 1);
if (!str)
return (0);
ft_memcpy(str, s1, ft_strlen(s1));
str[ft_strlen(s1)] = '\0';
return (str);
}