36 lines
1.2 KiB
C
36 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strsub.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2015/11/26 10:57:04 by scebula #+# #+# */
|
|
/* Updated: 2015/12/04 00:57:45 by scebula ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
char *ft_strsub(char const *s, unsigned int start, size_t len)
|
|
{
|
|
char *str;
|
|
size_t i;
|
|
unsigned int k;
|
|
|
|
if (len > (ft_strlen(s) - start) || start > ft_strlen(s))
|
|
return (NULL);
|
|
str = ft_strnew(len);
|
|
if (str == NULL)
|
|
return (NULL);
|
|
k = start;
|
|
i = 0;
|
|
while (i < len)
|
|
{
|
|
str[i] = s[k];
|
|
i++;
|
|
k++;
|
|
}
|
|
return (str);
|
|
}
|