libft
Loading...
Searching...
No Matches
ft_strdup.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* ft_strdup.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: tspoof <tspoof@student.hive.fi> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2022/11/03 14:50:57 by tspoof #+# #+# */
9/* Updated: 2022/11/03 15:09:08 by tspoof ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#include "libft.h"
14
15char *ft_strdup(const char *s1)
16{
17 char *ptr;
18 size_t size;
19
20 size = sizeof(char) * ft_strlen(s1) + 1;
21 ptr = (char *)malloc(size);
22 if (!ptr)
23 return (NULL);
24 ft_strlcpy(ptr, s1, size);
25 return (ptr);
26}
char * ft_strdup(const char *s1)
Duplicates a string.
Definition ft_strdup.c:15
size_t ft_strlcpy(char *dst, const char *src, size_t dstsize)
Copies string to destination.
Definition ft_strlcpy.c:15
size_t ft_strlen(const char *s)
Length of the string.
Definition ft_strlen.c:15