-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strdup.c
More file actions
32 lines (29 loc) · 1.14 KB
/
ft_strdup.c
File metadata and controls
32 lines (29 loc) · 1.14 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
32
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: salee <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/06/01 12:34:07 by salee #+# #+# */
/* Updated: 2021/06/01 12:34:13 by salee ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(char *src)
{
size_t i;
size_t src_length;
char *dest;
i = 0;
src_length = ft_strlen(src);
dest = malloc(src_length + 1);
if (dest == NULL)
return (NULL);
while (i <= src_length)
{
dest[i] = src[i];
i++;
}
return (dest);
}