libft
src
ft_strsub.c
Go to the documentation of this file.
1
/* ************************************************************************** */
3
/* */
4
/* ::: :::::::: */
5
/* ft_strsub.c :+: :+: :+: */
6
/* +:+ +:+ +:+ */
7
/* By: unite <marvin@42.fr> +#+ +:+ +#+ */
8
/* +#+#+#+#+#+ +#+ */
9
/* Created: 2019/09/05 11:49:21 by unite #+# #+# */
10
/* Updated: 2020/07/16 02:43:54 by unite ### ########.fr */
11
/* */
12
/* ************************************************************************** */
13
14
#include "
libft.h
"
15
28
char
*
ft_strsub
(
char
const
*s,
unsigned
int
start,
size_t
len)
29
{
30
char
*sub;
31
32
if
(!s ||
33
!(sub =
ft_strnew
(len)))
34
return
(NULL);
35
ft_strncpy
(sub, s + start, len);
36
return
(sub);
37
}
ft_strsub
char * ft_strsub(char const *s, unsigned int start, size_t len)
Copies a substring from a string.
Definition:
ft_strsub.c:28
libft.h
ft_strnew
char * ft_strnew(size_t size)
Allocates a fresh string.
Definition:
ft_strnew.c:25
ft_strncpy
char * ft_strncpy(char *dst, const char *src, size_t len)
Replicates behaviour of strncpy from libc.
Definition:
ft_strncpy.c:20
Generated by
1.8.16