27 lines
1.1 KiB
C
27 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strsub.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: tchivert <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2019/04/07 13:56:40 by tchivert #+# #+# */
|
|
/* Updated: 2019/09/04 05:13:34 by tchivert ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
char *ft_strsub(char const *s, unsigned int start, size_t len)
|
|
{
|
|
char *dest;
|
|
|
|
if (!s)
|
|
return (NULL);
|
|
if (!(dest = (char *)malloc(sizeof(char) * len + 1)))
|
|
return (NULL);
|
|
ft_strncpy(dest, (char *)s + start, (int)len);
|
|
dest[len] = '\0';
|
|
return (dest);
|
|
}
|