19 lines
No EOL
320 B
C
19 lines
No EOL
320 B
C
#include "libft.h"
|
|
#include <stdlib.h>
|
|
|
|
char *ft_strdup(const char *s)
|
|
{
|
|
size_t len = 0;
|
|
char *dup;
|
|
size_t i;
|
|
|
|
while (s[len])
|
|
len++;
|
|
dup = (char *)malloc(len + 1);
|
|
if (!dup)
|
|
return NULL;
|
|
for (i = 0; i < len; i++)
|
|
dup[i] = s[i];
|
|
dup[len] = '\0';
|
|
return (dup);
|
|
} |