-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strdup.c
More file actions
34 lines (31 loc) · 1.12 KB
/
ft_strdup.c
File metadata and controls
34 lines (31 loc) · 1.12 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
33
34
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: atahiri <atahiri@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/06/29 09:51:55 by atahiri #+# #+# */
/* Updated: 2021/06/29 09:52:33 by atahiri ### ########.fr */
/* */
/* ************************************************************************** */
#include "pipex.h"
char *ft_strdup(const char *str)
{
char *ptr;
unsigned int i;
i = 0;
while (str[i])
i++;
ptr = malloc(i + 1);
if (!ptr)
return (NULL);
i = 0;
while (str[i])
{
ptr[i] = str[i];
i++;
}
ptr[i] = '\0';
return (ptr);
}