|
Libft
Custom implementation of core libc functions with additional utility helpers.
|
String manipulation utilities. More...
Functions | |
| char ** | str_split (char const *s, char c) |
| Splits a string into an array of strings using a delimiter. | |
| char * | str_chr (const char *s, int c) |
| Locates the first occurrence of a character in a string. | |
| char * | str_dup (const char *s1) |
| Duplicates a string. | |
| void | str_iteri (char *s, void(*f)(unsigned int, char *)) |
| Applies a function to each character of a string with its index. | |
| char * | str_join (char const *s1, char const *s2) |
| Concatenates two strings into a new string. | |
| size_t | str_lcat (char *dst, const char *src, size_t dstsize) |
| Appends src to dst with size limit. | |
| size_t | str_lcpy (char *dst, const char *src, size_t dstsize) |
| Copies src to dst with size limit. | |
| size_t | str_len (const char *s) |
| Calculates the length of a string. | |
| char * | str_mapi (char const *s, char(*f)(unsigned int, char)) |
| Creates a new string by applying a function to each character. | |
| int | str_ncmp (const char *s1, const char *s2, size_t n) |
| Compares at most n characters of two strings. | |
| char * | str_nstr (const char *haystack, const char *needle, size_t len) |
| Locates a substring within a string, limited by length. | |
| char * | str_rchr (const char *s, int c) |
| Locates the last occurrence of a character in a string. | |
| char * | str_trim (char const *s1, char const *set) |
| Trims characters from the beginning and end of a string. | |
| char * | str_sub (char const *s, unsigned int start, size_t len) |
| Extracts a substring from a string. | |
String manipulation utilities.
Functions to search, copy, compare and transform strings.
| char * str_chr | ( | const char * | s, |
| int | c ) |
Locates the first occurrence of a character in a string.
| s | String to search (borrowed). |
| c | Character to find. |

| char * str_dup | ( | const char * | s1 | ) |
Duplicates a string.
| s1 | String to duplicate (borrowed). |

| void str_iteri | ( | char * | s, |
| void(* | f )(unsigned int, char *) ) |
Applies a function to each character of a string with its index.
| s | String to iterate (modified in place). |
| f | Function taking index and character pointer. |
| char * str_join | ( | char const * | s1, |
| char const * | s2 ) |
Concatenates two strings into a new string.
| s1 | First string (borrowed). |
| s2 | Second string (borrowed). |

| size_t str_lcat | ( | char * | dst, |
| const char * | src, | ||
| size_t | dstsize ) |
Appends src to dst with size limit.
| dst | Destination buffer (must be null-terminated). |
| src | Source string. |
| dstsize | Total size of destination buffer. |

| size_t str_lcpy | ( | char * | dst, |
| const char * | src, | ||
| size_t | dstsize ) |
Copies src to dst with size limit.
| dst | Destination buffer. |
| src | Source string. |
| dstsize | Size of destination buffer. |

| size_t str_len | ( | const char * | s | ) |
Calculates the length of a string.
| s | String to measure. |

| char * str_mapi | ( | char const * | s, |
| char(* | f )(unsigned int, char) ) |
Creates a new string by applying a function to each character.
| s | String to transform (borrowed). |
| f | Function taking index and character, returning new character. |

| int str_ncmp | ( | const char * | s1, |
| const char * | s2, | ||
| size_t | n ) |
Compares at most n characters of two strings.
| s1 | First string. |
| s2 | Second string. |
| n | Maximum number of characters to compare. |
| char * str_nstr | ( | const char * | haystack, |
| const char * | needle, | ||
| size_t | len ) |
Locates a substring within a string, limited by length.
| haystack | String to search in (borrowed). |
| needle | Substring to find (borrowed). |
| len | Maximum characters to search. |
| char * str_rchr | ( | const char * | s, |
| int | c ) |
Locates the last occurrence of a character in a string.
| s | String to search (borrowed). |
| c | Character to find. |
| char ** str_split | ( | char const * | s, |
| char | c ) |
Splits a string into an array of strings using a delimiter.
| s | String to split (borrowed). |
| c | Delimiter character. |

| char * str_sub | ( | char const * | s, |
| unsigned int | start, | ||
| size_t | len ) |
Extracts a substring from a string.
| s | Source string (borrowed). |
| start | Starting index. |
| len | Maximum length of substring. |


| char * str_trim | ( | char const * | s1, |
| char const * | set ) |
Trims characters from the beginning and end of a string.
| s1 | String to trim (borrowed). |
| set | Characters to trim (borrowed). |
