-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strdup.c
29 lines (26 loc) · 1.08 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
29
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rvandepu <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/18 22:11:16 by rvandepu #+# #+# */
/* Updated: 2023/10/18 22:15:37 by rvandepu ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "libft.h"
char *ft_strdup(const char *s)
{
char *d;
int i;
i = ft_strlen(s);
d = malloc(i + 1);
if (d == NULL)
return (d);
d[i] = '\0';
while (i--)
d[i] = s[i];
return (d);
}