libft
Functions
ft_strsplit.c File Reference
#include "libft.h"
#include <stdlib.h>
+ Include dependency graph for ft_strsplit.c:

Go to the source code of this file.

Functions

char ** ft_strsplit (char const *s, char delim)
 Splits a string on whitespace characters. More...
 

Function Documentation

◆ ft_strsplit()

char** ft_strsplit ( char const *  s,
char  delim 
)

Splits a string on whitespace characters.

Allocates (with malloc) and returns an array of “fresh” strings (all ending with '\0', including the array itself) obtained by splitting s using the character c as a delimiter.

Example
ft_strsplit("*hello*fellow***students*", ’*’) returns the array ["hello", "fellow", "students"].
Parameters
sThe string to split.
delimThe delimiter character.
Returns
The array of “fresh” strings result of the split or NULL if any of the allocations failed.

Definition at line 70 of file ft_strsplit.c.