33 lines
1.2 KiB
C
33 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_substr.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2019/11/19 17:20:51 by hulamy #+# #+# */
|
|
/* Updated: 2019/11/19 17:24:10 by hulamy ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
/*
|
|
** create a copy of a portion of s, begining at start and of length len
|
|
*/
|
|
|
|
#include "libft.h"
|
|
|
|
char *ft_substr(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);
|
|
}
|