libft
Functions
ft_strsub.c File Reference
#include "libft.h"
+ Include dependency graph for ft_strsub.c:

Go to the source code of this file.

Functions

char * ft_strsub (char const *s, unsigned int start, size_t len)
 Copies a substring from a string. More...
 

Function Documentation

◆ ft_strsub()

char* ft_strsub ( char const *  s,
unsigned int  start,
size_t  len 
)

Copies a substring from a string.

Allocates (with malloc) and returns a “fresh” substring from the string given as argument. The substring begins at index start and is of size len. If start and len aren’t refering to a valid substring, the behavior is undefined.

Parameters
sThe string from which create the substring.
startThe start index of the substring.
lenThe size of the substring.
Returns
The substring or NULL if allocation failed.

Definition at line 28 of file ft_strsub.c.