Files
42_old_fillit/libft/src/str/ft_strsub.c

33 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strsub.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/14 21:19:52 by hulamy #+# #+# */
/* Updated: 2019/03/25 15:27:14 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
/*
** create a copy of a portion of s, begining at start and of length len
*/
#include "libft.h"
char *ft_strsub(char const *s, unsigned int start, size_t len)
{
char *str;
size_t i;
if (!s)
return (NULL);
if (!(str = ft_strnew(len)))
return (NULL);
i = 0;
while (i < len)
str[i++] = s[start++];
return (str);
}