mise a jour de plusieurs fonctions

This commit is contained in:
Hugo LAMY
2019-11-19 18:16:42 +01:00
parent c612c9bae7
commit 966241a6df
11 changed files with 333 additions and 7 deletions

32
srcs/ft_substr.c Normal file
View 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);
}