-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strdup.c
executable file
·26 lines (23 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jchoy-me <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/11 14:29:21 by jchoy-me #+# #+# */
/* Updated: 2023/07/13 15:23:13 by jchoy-me ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s1)
{
char *ptr;
int nbytes;
nbytes = ft_strlen(s1) + 1;
ptr = (char *) malloc(sizeof(char) * nbytes);
if (ptr == NULL)
return (NULL);
ft_strlcpy(ptr, s1, nbytes);
return (ptr);
}