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
atoi
And using malloc:
calloc strdup
malloc 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 bonus
Linked 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 test
Makefile 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 🙌