You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

27 lines
1.1 KiB

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strsub.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: emartine <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/08 15:27:00 by emartine #+# #+# */
/* Updated: 2017/11/08 15:27:01 by emartine ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strsub(char const *s, unsigned intstart, size_t len)
{
char *r;
size_t i;
if (!s || !(r = (char *)malloc(len + 1)))
return (NULL);
i = 0;
while (i < len && s[i])
r[i++] = s[intstart++];
r[i] = '\0';
return (r);
}