-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strcut.c
More file actions
29 lines (26 loc) · 1.19 KB
/
ft_strcut.c
File metadata and controls
29 lines (26 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_cutstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jagarcia <jagarcia@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/02/13 18:23:20 by jagarcia #+# #+# */
/* Updated: 2018/02/19 12:27:03 by jagarcia ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strcut(char *str, int start, int end)
{
char *new;
if (!str)
return (NULL);
if (end <= start || start < 0 || end < 0)
return (str);
new = ft_strnew(ft_strlen(str) - (end - start));
if (!new || !str)
return (NULL);
ft_strncpy(new, str, start);
ft_strcat(new, str + end);
return (new);
}