A custom C library project from 42 School
Libft is an individual project at 42 School aimed at recreating essential C standard library functions, along with additional utilities. This library serves as a foundation for future projects at 42, where the use of certain standard libraries is restricted. As we progress through the curriculum, this library will expand with more custom functions tailored to our needs.
The goal? Build a robust, reusable, and efficient set of tools from scratch.
Functions for character handling:
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
— Validates if a character is in the ASCII set.ft_isprint
— Checks if a character is printable.ft_toupper
— Converts a character to uppercase.ft_tolower
— Converts a character to lowercase.
Functions for string and memory manipulation:
ft_strlen
— Calculates the length of a string.ft_memset
— Fills memory with a constant byte.ft_bzero
— Sets a memory block to zero.ft_memcpy
— Copies memory from source to destination.ft_memmove
— Copies memory, handling overlapping areas.ft_strlcpy
— Copies a string with size limitation.ft_strlcat
— Concatenates strings with size limitation.ft_strchr
— Finds the first occurrence of a character.ft_strrchr
— Finds the last occurrence of a character.ft_strncmp
— Compares two strings up to n characters.ft_memchr
— Scans memory for a specific character.ft_memcmp
— Compares two memory blocks.ft_strnstr
— Locates a substring within a string.ft_strdup
— Duplicates a string.
Functions for memory allocation and conversion:
Custom utility functions:
ft_substr
— Extracts a substring from a string.ft_strjoin
— Concatenates two strings.ft_strtrim
— Trims specific characters from a string.ft_split
— Splits a string by a delimiter.ft_itoa
— Converts an integer to a string.ft_strmapi
— Applies a function to each character of a string.ft_striteri
— Applies a function to each character with index.ft_putchar_fd
— Outputs a character to a file descriptor.ft_putstr_fd
— Outputs a string to a file descriptor.ft_putendl_fd
— Outputs a string + newline to a file descriptor.ft_putnbr_fd
— Outputs a number to a file descriptor.
Functions for linked list management:
ft_lstnew
— Creates a new linked list node.ft_lstadd_front
— Adds a node to the front of the list.ft_lstsize
— Counts the number of nodes in the list.ft_lstlast
— Returns the last node of the list.ft_lstadd_back
— Adds a node to the end of the list.ft_lstclear
— Deletes and frees the entire list.ft_lstiter
— Applies a function to each list element.ft_lstmap
— Maps a function over the list, creating a new one.
-
Clone repository
git clone git@github.com:doooriian/Libft.git
-
Go inside project directory and run
make
cd Libft make
-
To use the library in your code,
#include
the following header#include "libft.h"
This project was tested using Francinette, a widely-used third-party tester designed for 42 School projects.
Here’s my score for the Libft project:
Feel free to reach out or contribute to this project via GitHub!