-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strsub.c
More file actions
31 lines (28 loc) · 1.19 KB
/
ft_strsub.c
File metadata and controls
31 lines (28 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
30
31
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strsub.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tyassine <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/28 22:20:58 by tyassine #+# #+# */
/* Updated: 2015/12/05 17:06:34 by tyassine ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strsub(char const *s, unsigned int start, size_t len)
{
char *result;
size_t i;
if (!(result = (char *)malloc(sizeof(char) * (len + 1))))
return (NULL);
i = 0;
while (i < len && s[start] != '\0')
{
result[i] = (char)s[start];
start++;
i++;
}
result[i] = '\0';
return (result);
}