47 lines
1.3 KiB
C
47 lines
1.3 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strdup.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2022/07/22 09:56:34 by cchauvet #+# #+# */
|
|
/* Updated: 2022/08/01 14:35:27 by cchauvet ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include <stdlib.h>
|
|
|
|
char *ft_strcpy(char *dest, char *src)
|
|
{
|
|
int i;
|
|
|
|
i = 0;
|
|
while (src[i] != 0)
|
|
{
|
|
dest[i] = src[i];
|
|
i++;
|
|
}
|
|
dest[i] = '\0';
|
|
return (dest);
|
|
}
|
|
|
|
unsigned int ft_strlen(char *str)
|
|
{
|
|
unsigned int i;
|
|
|
|
i = 0;
|
|
while (str[i] != 0)
|
|
i++;
|
|
return (i);
|
|
}
|
|
|
|
char *ft_strdup(char *src)
|
|
{
|
|
char *dest;
|
|
|
|
dest = malloc(sizeof(*dest) * (ft_strlen(src) + 1));
|
|
ft_strcpy(dest, src);
|
|
return (dest);
|
|
}
|