-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strdup.c
More file actions
31 lines (28 loc) · 1.11 KB
/
ft_strdup.c
File metadata and controls
31 lines (28 loc) · 1.11 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: ychihab <ychihab@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 10:07:30 by ychihab #+# #+# */
/* Updated: 2022/10/24 08:18:14 by ychihab ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(char *src)
{
int i;
char *ptr;
i = 0;
ptr = malloc(sizeof(char) * ft_strlen(src) + 1);
if (ptr == NULL )
return (0);
while (*src)
{
ptr[i] = *src++;
i++;
}
ptr[i] = '\0';
return (ptr);
}