first commit
This commit is contained in:
32
ended/C07/ex00/ft_strdup.c
Normal file
32
ended/C07/ex00/ft_strdup.c
Normal file
@ -0,0 +1,32 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strdup.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ajoly <ajoly@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/28 18:42:08 by ajoly #+# #+# */
|
||||
/* Updated: 2022/08/04 09:17:22 by ajoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
char *ft_strdup(char *src)
|
||||
{
|
||||
int i;
|
||||
char *dest;
|
||||
|
||||
i = 0;
|
||||
while (src[i])
|
||||
i++;
|
||||
dest = malloc(i);
|
||||
i = 0;
|
||||
while (src[i])
|
||||
{
|
||||
dest[i] = src[i];
|
||||
i++;
|
||||
}
|
||||
dest[i] = '\0';
|
||||
return (dest);
|
||||
}
|
Reference in New Issue
Block a user