|
libft
|
Splits a string into substrings using a single delimiter character. More...
#include "libft.h"
Include dependency graph for ft_split.c:Functions | |
| static int | ft_fill_array (char **array, const char *s, char c, size_t w_count) |
| Fills the output array with substrings from input. | |
| char ** | ft_split (const char *s, char c) |
| Splits a string into substrings based on a delimiter character. | |
| static size_t | ft_w_count (const char *str, char c) |
| Counts how many substrings will result from splitting. | |
Splits a string into substrings using a single delimiter character.
This file implements the ft_split function, which breaks a string into an array of substrings based on a single delimiter character. Substrings are dynamically allocated, and the output is a NULL-terminated array. Internal helpers handle word counting and array filling.
|
static |
Fills the output array with substrings from input.
Allocates substrings from s using ft_substr and stores them in the provided array. The array is NULL-terminated. On allocation failure, previously allocated substrings are freed.
| array | The output array of substrings. |
| s | The input string to split. |
| c | The delimiter character. |
| w_count | The number of substrings to extract. |
|
static |
Counts how many substrings will result from splitting.
Traverses the input string and counts how many substrings (non-empty sequences not interrupted by the delimiter) will be generated.
| str | The input string to scan. |
| c | The delimiter character. |