This commit is contained in:
Camille Chauvet
2023-05-17 16:45:25 +00:00
commit 29ed24d567
619 changed files with 16119 additions and 0 deletions

45
C/c07v1/ex00/ft_strdup.c Normal file
View File

@ -0,0 +1,45 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/22 09:56:34 by cchauvet #+# #+# */
/* Updated: 2022/07/26 17:58:31 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++;
}
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(src) * ft_strlen(src));
ft_strcpy(dest, src);
return (dest);
}