-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strsub.c
More file actions
executable file
·36 lines (33 loc) · 1.21 KB
/
Copy pathft_strsub.c
File metadata and controls
executable file
·36 lines (33 loc) · 1.21 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
30
31
32
33
34
35
36
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strsub.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wdebs <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/09/23 22:10:38 by wdebs #+# #+# */
/* Updated: 2017/02/27 04:55:57 by wdebs ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strsub(char const *s, unsigned int start, size_t len)
{
char *new_str;
size_t i;
i = 0;
if (s == NULL)
return (NULL);
new_str = (char *)malloc(len + 1);
if (new_str != NULL)
{
while (i < len)
{
new_str[i] = s[start];
i++;
start++;
}
new_str[i] = '\0';
return (new_str);
}
return (NULL);
}