A foundational project at 42 School, aimed at re-coding essential C standard library functions and learning how to build your own reusable library.
The Libft project is about creating your own C library that re-implements many of the functions you will use throughout your future projects. It helps you understand the inner workings of common C functions, memory handling, and linked lists β building a strong foundation for low-level programming.
Someone lost in C pointers π΅βπ«
libft/
βββ .github/workflows
β βββ run-test.yaml
βββ Makefile
βββ includes/
β βββ libft.h
βββ src/
β βββ Mandatory/
β β βββ *.c
β βββ Bonus/
β βββ *.c
βββ README.md-
Your project must follow 42βs Norm (norminette).
-
Your functions must not crash (no segfaults, double frees, or memory leaks).
-
All dynamically allocated memory must be properly freed.
-
You must include a Makefile with at least the rules:
NAME, all, clean, fclean, re
-
The bonus part should be compiled with:
make bonus
-
You are encouraged to create and use test programs for your own validation.
When the norminette says OK β
π
| Requirement | Details |
|---|---|
| Library Name | libft.a |
| Files to turn in | *.c, libft.h, Makefile |
| Compiler | cc |
| Flags | -Wall -Wextra -Werror |
| No global variables | β Required |
| Create archive with | ar (not libtool) |
Re-code the following C standard library functions (without using restrict):
isalpha isdigit isalnum isascii isprint
strlen memset bzero memcpy memmove
strlcpy strlcat toupper tolower strchr
strrchr strncmp memchr memcmp strnstr
atoiAnd using malloc:
calloc strdupmalloc never returns NULLβ¦ right? π
Functions that are not in libc or have modified behavior:
| Function | Description |
|---|---|
| ft_substr | Returns a substring from a string. |
| ft_strjoin | Concatenates two strings. |
| ft_strtrim | Trims characters from the beginning and end of a string. |
| ft_split | Splits a string using a delimiter. |
| ft_itoa | Converts an integer to a string. |
| ft_strmapi | Applies a function to each character of a string (creates a new string). |
| ft_striteri | Applies a function to each character of a string (in-place). |
| 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 followed by a newline. |
| ft_putnbr_fd | Outputs an integer to a file descriptor. |
Once youβve completed the mandatory part, you can implement linked list functions.
typedef struct s_list
{
void *content;
struct s_list *next;
} t_list;| Function | Description |
|---|---|
| ft_lstnew | Creates a new list node. |
| ft_lstadd_front | Adds a node at the beginning. |
| ft_lstsize | Returns the number of nodes. |
| ft_lstlast | Returns the last node. |
| ft_lstadd_back | Adds a node at the end. |
| ft_lstdelone | Frees a single node. |
| ft_lstclear | Frees an entire list. |
| ft_lstiter | Iterates over a list and applies a function. |
| ft_lstmap | Creates a new list by applying a function to each node. |
To compile with the bonus part:
make bonusLinked list chaos πͺ’π
# Compile the library
make
# Compile the bonus functions
make bonus
# Clean object files
make clean
# Remove binaries and library
make fclean
# Recompile from scratch
make re
# Build and run test program
make testMakefile says Done compiling ππ
If you want to check your codeβs Norminette or Build automatically through GitHub:
- Go to your repository on GitHub.
- Click on the "Actions" tab.
- Find the workflow named βCheck the Norminette or Build of the codeβ.
- Click βRun workflowβ.
- In the dropdown, select the type β
Choose the type of test?. - Click βRun workflowβ again.
GitHub Actions will automatically test your code against the Norminette or Build rules and display the result in the Actions panel β .
Waiting for CI to pass β³π€
- Test your functions one by one before adding them to the library.
- Keep helper (static) functions internal β donβt expose them in libft.h.
- Check memory leaks.
- Expand your Libft as you progress β itβs your foundation for future 42 projects.
By the end of this project, you will:
- Understand how the C standard library works internally
- Have a custom reusable C library for all future projects
- Master memory management, string manipulation, and linked list operations
Made with β€οΈ as part of the 42 School Curriculum
βUnderstanding the foundation of C is the first step toward mastering programming.β
Thanks for reading π







