base struct
This commit is contained in:
30
lib/libft/srcs/str/ft_strdup.c
Normal file
30
lib/libft/srcs/str/ft_strdup.c
Normal file
@@ -0,0 +1,30 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strdup.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/14 15:38:09 by nalebrun #+# #+# */
|
||||
/* Updated: 2024/11/25 16:16:02 by nalebrun ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../libft.h"
|
||||
|
||||
char *ft_strdup(const char *s1)
|
||||
{
|
||||
char *out;
|
||||
unsigned long int i;
|
||||
|
||||
out = ft_calloc(ft_strlen(s1) + 1, sizeof(char));
|
||||
if (!out || !s1)
|
||||
return (NULL);
|
||||
i = 0;
|
||||
while (s1[i])
|
||||
{
|
||||
out[i] = s1[i];
|
||||
i++;
|
||||
}
|
||||
return (out);
|
||||
}
|
||||
Reference in New Issue
Block a user