-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathft_strdup.c
More file actions
31 lines (28 loc) · 1.2 KB
/
Copy pathft_strdup.c
File metadata and controls
31 lines (28 loc) · 1.2 KB
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: jperpect <jperpect@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/30 13:29:46 by jperpect #+# #+# */
/* Updated: 2024/06/18 14:32:46 by jperpect ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s)
{
char *copy;
if (s == NULL)
return (NULL);
copy = ft_calloc(ft_strlen(s) + 1, sizeof(char));
if (copy != NULL)
ft_strlcpy(copy, s, ft_strlen(s) + 1);
return (copy);
}
/*
int main(int ac, char **av)
{
printf("%s\n",ft_strdup(av[1]));
printf("%s",strdup(av[1]));
}*/