A complete reimplementation of the C standard library — from scratch, without using any of the original functions.
"This project taught me how the C standard library actually works under the hood — how strings are traversed byte by byte, how memory is allocated and manipulated manually, and what it truly means to write reliable, reusable code."
Understanding these fundamentals is what separates a developer who uses tools from one who understands them. Every senior engineer working in systems programming, embedded, or performance-critical environments thinks at this level of abstraction.
A fully functional personal C library (libft.a) covering:
| Function | Description |
|---|---|
ft_memset |
Fill memory with a byte value |
ft_bzero |
Zero out a memory area |
ft_memcpy |
Copy memory areas |
ft_memmove |
Safe memory copy with overlap handling |
ft_memchr |
Locate byte in memory |
ft_memcmp |
Compare memory areas |
ft_calloc |
Allocate and zero-initialize memory |
| Function | Description |
|---|---|
ft_strlen |
String length |
ft_strdup |
Duplicate a string |
ft_strchr / ft_strrchr |
Character search |
ft_strncmp |
String comparison |
ft_strlcpy / ft_strlcat |
Safe string copy and concat |
ft_strnstr |
Substring search |
ft_substr |
Extract substring |
ft_strjoin |
Join two strings |
ft_strtrim |
Trim characters from edges |
ft_split |
Split string by delimiter |
ft_strmapi / ft_striteri |
Functional map over string |
| Function | Description |
|---|---|
ft_atoi |
String to integer |
ft_itoa |
Integer to string |
ft_toupper / ft_tolower |
Character case conversion |
| Function | Description |
|---|---|
ft_putchar_fd |
Write char to file descriptor |
ft_putstr_fd |
Write string to file descriptor |
ft_putendl_fd |
Write string + newline |
ft_putnbr_fd |
Write integer |
| Function | Description |
|---|---|
ft_lstnew |
Create new node |
ft_lstadd_front / ft_lstadd_back |
Add node to front/back |
ft_lstsize |
Count list nodes |
ft_lstlast |
Get last node |
ft_lstdelone / ft_lstclear |
Delete node(s) |
The implementation of ft_split correctly handles edge cases such as consecutive delimiters, leading/trailing delimiters, and empty strings — situations where many naive implementations silently fail or leak memory. This demonstrates careful thinking about boundary conditions, not just the happy path.
git clone https://github.com/gustavofsousa/libft-42.git
cd libft-42
makeThis produces libft.a. To use it in your project:
#include "libft.h"Compile with:
gcc your_file.c -L. -lft -o your_program| Target | Action |
|---|---|
make |
Build the library |
make bonus |
Build with linked list functions |
make clean |
Remove object files |
make fclean |
Remove object files and library |
make re |
Full rebuild |
- Manual memory management in C
- Pointer arithmetic and string manipulation
- Makefile and static library creation (
ar) - Defensive programming and edge case handling
- Linked list data structure implementation
This project was developed as part of the 42 School curriculum.
Made with ☕ at 42 Rio de Janeiro