Reimplementation of a simplified C standard library for the 42 curriculum.
This project provides custom implementations of many libc functions, additional
string/memory utilities, and a full linked list API.
Project developed at 42 Telefónica by Diego Valladares Ortega.
libft is a static C library containing reusable low-level functions that are
commonly needed in future projects. It includes:
- Character checks (
ft_isalpha,ft_isdigit, …) - Memory manipulation (
ft_memset,ft_memcpy,ft_calloc, …) - String handling (
ft_strlen,ft_strlcpy,ft_split, …) - Conversions (
ft_atoi,ft_itoa) - File descriptor helpers (
ft_put*functions) - A complete linked list implementation (
t_listand operations)
The purpose is to avoid rewriting basic utilities in future projects and gain a deeper understanding of how standard library functions work internally.
src/ # All ft_*.c files (implementations)
include/ # Public header: libft.h
tests/ # Optional test files (not part of 42 requirement)
Makefile # Builds the static library
🔧 Build Instructions
Clone the repository:
git clone https://github.com/<TU_USUARIO>/libft.git
cd libft
Build the library:
make
This will generate:
./libft.a
Clean object files:
make clean
Remove objects + library:
make fclean
Recompile everything:
make re
🧪 Testing (Optional) A simple test file is included in:
tests/main.c
Compile and run:
cc tests/main.c -L. -lft -Iinclude -o test_libft
./test_libft
You can add your own test cases to validate more functions.
📚 Implemented Functions Part 1 – Libc Functions ft_isalpha
ft_isdigit
ft_isalnum
ft_isascii
ft_isprint
ft_strlen
ft_memset
ft_bzero
ft_memcpy
ft_memmove
ft_strlcpy
ft_strlcat
ft_toupper
ft_tolower
ft_strchr
ft_strrchr
ft_strncmp
ft_memchr
ft_memcmp
ft_strnstr
ft_atoi
ft_calloc
ft_strdup
Part 2 – Additional Functions
ft_substr
ft_strjoin
ft_strtrim
ft_split
ft_itoa
ft_strmapi
ft_striteri
ft_putchar_fd
ft_putstr_fd
ft_putendl_fd
ft_putnbr_fd
Bonus – Linked List Functions
Using the structure:
typedef struct s_list
{
void *content;
struct s_list *next;
} t_list;
Implemented:
ft_lstnew
ft_lstadd_front
ft_lstsize
ft_lstlast
ft_lstadd_back
ft_lstdelone
ft_lstclear
ft_lstiter
ft_lstmap
🧠 What I Learned
Inner workings of common libc functions
Memory allocation and manual management
Handling strings and pointers safely
Static library creation (ar)
Data structures: singly linked lists
Writing clean, reusable C code following 42 Norm
This project is licensed under the MIT License.
See the LICENSE file for more details.