29 lines
1.1 KiB
C
29 lines
1.1 KiB
C
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* ft_strsub.c :+: :+: :+: */
|
||
|
/* +:+ +:+ +:+ */
|
||
|
/* By: gbrochar <marvin@42.fr> +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2015/11/29 09:14:36 by gbrochar #+# #+# */
|
||
|
/* Updated: 2015/12/08 15:34:26 by gbrochar ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
#include "libft.h"
|
||
|
|
||
|
char *ft_strsub(char const *s, unsigned int start, size_t len)
|
||
|
{
|
||
|
char *str;
|
||
|
size_t i;
|
||
|
|
||
|
i = 0;
|
||
|
str = (char *)malloc((len + 1) * sizeof(char));
|
||
|
if (!str)
|
||
|
return (NULL);
|
||
|
while (i < len)
|
||
|
str[i++] = s[start++];
|
||
|
str[i] = '\0';
|
||
|
return (str);
|
||
|
}
|