Push the final version
This commit is contained in:
commit
d0fe1fb2fb
28 changed files with 1459 additions and 0 deletions
32
libft/ft_substr.c
Executable file
32
libft/ft_substr.c
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_substr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:54:42 by rparodi #+# #+# */
|
||||
/* Updated: 2024/04/17 19:45:46 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/push_swap.h"
|
||||
|
||||
char *ft_substr(char const *s, unsigned int start, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
size_t j;
|
||||
char *str;
|
||||
|
||||
i = start;
|
||||
if (start >= ft_len(s))
|
||||
return (ft_strdup(""));
|
||||
if (len + start > (ft_len(s)))
|
||||
len = ft_len(s) - start;
|
||||
j = 0;
|
||||
str = (char *)malloc(len + 1);
|
||||
if (!str || !s)
|
||||
return (free(str), ft_strdup(""));
|
||||
ft_strlcpy(str, s + start, len + 1);
|
||||
return (str);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue