mise a jour de plusieurs fonctions
This commit is contained in:
32
srcs/ft_substr.c
Normal file
32
srcs/ft_substr.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 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);
|
||||
}
|
||||
Reference in New Issue
Block a user