-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strdup.c
More file actions
executable file
·34 lines (32 loc) · 1.15 KB
/
Copy pathft_strdup.c
File metadata and controls
executable file
·34 lines (32 loc) · 1.15 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: ybolivar <ybolivar@student.42madrid.c +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/25 13:29:01 by ybolivar #+# #+# */
/* Updated: 2022/03/25 13:38:23 by ybolivar ### ########.fr */
/* */
/* ************************************************************************** */
#include"libft.h"
char *ft_strdup(const char *s1)
{
char *str;
int i;
int size;
size = 0;
while (s1[size])
++size;
str = malloc(sizeof(char) * (size + 1));
if (!str)
return (NULL);
i = 0;
while (s1[i])
{
str[i] = s1[i];
i++;
}
str[i] = '\0';
return (str);
}