A custom C library featuring re-implementations of standard libc functions and other useful utilities. A core project for the 42 school curriculum.
📌 Index • ✨ What is Libft? • 📑 List of Fucntions • Functions from `` • Functions from `` • Functions from `` • Non-standard functions
Libft is a custom C library developed as a core project for the 42 school curriculum. It contains re-implementations of many standard C library functions, as well as a suite of additional utilities for string manipulation, memory management, and linked list operations.
This project is designed to provide a foundational set of tools for future C projects where standard libraries may be restricted.
The library is organized into several parts: re-implementations of standard libc functions, a set of non-standard utility functions, and functions for manipulating linked lists.
These functions mimic the behavior of their standard C library counterparts.
| Function | Description |
|---|---|
ft_isalpha |
Checks if a character is alphabetic. |
ft_isdigit |
Checks if a character is a digit (0-9). |
ft_isalnum |
Checks if a character is alphanumeric. |
ft_isascii |
Checks if a character fits into the ASCII character set. |
ft_isprint |
Checks if a character is printable. |
ft_toupper |
Converts a character to its uppercase equivalent. |
ft_tolower |
Converts a character to its lowercase equivalent. |
| Function | Description |
|---|---|
ft_strlen |
Calculates the length of a string. |
ft_memset |
Fills a block of memory with a specific value. |
ft_bzero |
Fills a block of memory with zero-valued bytes. |
ft_memcpy |
Copies a block of memory from a source to a destination. |
ft_memmove |
Copies a block of memory, handling overlapping areas safely. |
ft_strlcpy |
Copies a string to a buffer with size-checking. |
ft_strlcat |
Concatenates a string to a buffer with size-checking. |
ft_strchr |
Locates the first occurrence of a character in a string. |
ft_strrchr |
Locates the last occurrence of a character in a string. |
ft_strncmp |
Compares up to n characters of two strings. |
ft_memchr |
Scans memory for the first occurrence of a character. |
ft_memcmp |
Compares two blocks of memory. |
ft_strnstr |
Locates a substring within the first n bytes of a string. |
ft_strdup |
Duplicates a string by allocating new memory. |
| Function | Description |
|---|---|
ft_atoi |
Converts a string to an integer. |
ft_calloc |
Allocates memory for an array and initializes it to zero. |
A collection of useful functions not found in the standard C library.
| Function | Description |
|---|---|
ft_substr |
Allocates and returns a substring from a string. |
ft_strjoin |
Allocates and returns a new string, result of concatenating two strings. |
ft_strtrim |
Allocates and returns a copy of a string with specified characters removed from the beginning and end. |
ft_split |
Allocates and returns an array of strings obtained by splitting a string using a delimiter character. |
ft_itoa |
Allocates and returns a string representation of an integer. |
ft_strmapi |
Applies a function to each character of a string to create a new string. |
ft_striteri |
Applies a function to each character of a string. |
ft_putchar_fd |
Writes a single character to a given file descriptor. |
ft_putstr_fd |
Writes a string to a given file descriptor. |
ft_putendl_fd |
Writes a string to a file descriptor, followed by a newline. |
ft_putnbr_fd |
Writes an integer to a given file descriptor. |
Functions to create and manage a singly linked list.
| Function | Description |
|---|---|
ft_lstnew |
Creates a new list element. |
ft_lstadd_front |
Adds an element to the beginning of a list. |
ft_lstsize |
Counts the number of elements in a list. |
ft_lstlast |
Returns the last element of a list. |
ft_lstadd_back |
Adds an element to the end of a list. |
ft_lstdelone |
Frees the memory of a single list element. |
ft_lstclear |
Deletes and frees all elements of a list. |
ft_lstiter |
Applies a function to the content of each element in a list. |
ft_lstmap |
Creates a new list by applying a function to each element of an existing list. |
-
Clone the repository:
git clone https://github.com/jdecorte-be/libft.git cd libft -
Compile the library: The included
Makefileprovides several targets for building and managing the library.# Compiles source files and creates the static library libft.a make all # Removes object files (.o) make clean # Removes object files and the library file (libft.a) make fclean # Re-compiles the library from scratch make re
-
Include the header in your C source file:
#include "libft.h"
-
Compile your project and link it with the
libft.alibrary:# Example: Compiling main.c with libft gcc main.c -L. -lft -o my_program-L.tells the compiler to look for libraries in the current directory.-lftlinks thelibftlibrary.
If you find a bug or have a suggestion for improvement, please feel free to open an issue. Pull requests are also welcome!
Give a ⭐️ if you found this project helpful
