aboutsummaryrefslogtreecommitdiffstats
path: root/inc
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-02-21 16:29:51 +0100
committerThomas Vanbesien <tvanbesi@proton.me>2026-02-21 16:29:51 +0100
commita8f7e6e83bc4846c94c0489e0f6e0f807b35073e (patch)
tree0d245c73490427a39d4338da483e335a267c6917 /inc
parentfd62678a9cf38e3f70efbdd093c1012d448548e1 (diff)
downloadLibft-a8f7e6e83bc4846c94c0489e0f6e0f807b35073e.tar.gz
Libft-a8f7e6e83bc4846c94c0489e0f6e0f807b35073e.zip
Implement libft Part 2 with tests
Add ft_substr, ft_strjoin, ft_strtrim, ft_split, ft_itoa, ft_strmapi, ft_striteri, ft_putchar_fd, ft_putstr_fd, ft_putendl_fd, ft_putnbr_fd.
Diffstat (limited to 'inc')
-rw-r--r--inc/libft.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/inc/libft.h b/inc/libft.h
index d57cd8d..05a5ae9 100644
--- a/inc/libft.h
+++ b/inc/libft.h
@@ -72,6 +72,25 @@ size_t ft_strlcpy (char *dst, const char *src, size_t size);
size_t ft_strlcat (char *dst, const char *src, size_t size);
/** @brief Return a malloc'd duplicate of @p s. */
char *ft_strdup (const char *s);
+/**
+ * @brief Allocate a substring from @p s starting at @p start, at most @p len
+ * chars.
+ */
+char *ft_substr (char const *s, unsigned int start, size_t len);
+/** @brief Allocate the concatenation of @p s1 and @p s2. */
+char *ft_strjoin (char const *s1, char const *s2);
+/** @brief Trim characters in @p set from both ends of @p s1. */
+char *ft_strtrim (char const *s1, char const *set);
+/**
+ * @brief Split @p s by delimiter @p c into a NULL-terminated array of strings.
+ */
+char **ft_split (char const *s, char c);
+/** @brief Allocate the decimal string representation of @p n. */
+char *ft_itoa (int n);
+/** @brief Apply @p f to each character of @p s, returning a new string. */
+char *ft_strmapi (char const *s, char (*f) (unsigned int, char));
+/** @brief Apply @p f to each character of @p s in place, passing its index. */
+void ft_striteri (char *s, void (*f) (unsigned int, char *));
/* ======================================
* Memory operations
@@ -103,4 +122,17 @@ int ft_memcmp (const void *s1, const void *s2, size_t n);
*/
void *ft_calloc (size_t nmemb, size_t size);
+/* ======================================
+ * File descriptor output
+ * ====================================== */
+
+/** @brief Write character @p c to file descriptor @p fd. */
+void ft_putchar_fd (char c, int fd);
+/** @brief Write string @p s to file descriptor @p fd. */
+void ft_putstr_fd (char *s, int fd);
+/** @brief Write string @p s followed by a newline to @p fd. */
+void ft_putendl_fd (char *s, int fd);
+/** @brief Write integer @p n in decimal to @p fd. */
+void ft_putnbr_fd (int n, int fd);
+
#endif