Libft is a foundational C library that reimplements a selection of standard C library functions. It is often the very first project in the 42 curriculum, aiming to ensure students have a solid understanding of memory handling, string manipulation, and linked lists in C.
This project consists of re-creating common C standard library functions from <ctype.h>, <string.h>, <stdlib.h>, and <unistd.h>, as well as implementing custom utility functions and linked list manipulation tools.
- Character checks:
ft_isalpha,ft_isdigit,ft_isalnum,ft_isascii,ft_isprint - Memory manipulation:
ft_memset,ft_bzero,ft_memcpy,ft_memmove,ft_memchr,ft_memcmp - String operations:
ft_strlen,ft_strlcpy,ft_strlcat,ft_strchr,ft_strrchr,ft_strncmp,ft_strnstr,ft_strdup - Type conversions:
ft_atoi,ft_tolower,ft_toupper - Memory allocation:
ft_calloc - Advanced string manipulation:
ft_substr,ft_strjoin,ft_strtrim,ft_split,ft_itoa,ft_strmapi,ft_striteri - File descriptor output:
ft_putchar_fd,ft_putstr_fd,ft_putendl_fd,ft_putnbr_fd
ft_lstnew– Create a new list elementft_lstadd_front– Add element at the beginningft_lstsize– Count list elementsft_lstlast– Get the last elementft_lstadd_back– Add element at the endft_lstdelone– Delete a single elementft_lstclear– Clear the entire listft_lstiter– Apply a function to each elementft_lstmap– Map a function over the list into a new one
git clone https://github.com/adil-ech/libft
cd libft
makeThis will generate libft.a, a static library that you can link with your own C programs using:
gcc your_program.c -L. -lftIn your C file:
#include "libft.h"Then compile with:
gcc main.c -L. -lftEnsure that both libft.a and libft.h are present in your project directory or properly linked.
libft/
├── ft_*.c # Libft function implementations
├── ft_*.h # Header files (mostly libft.h)
├── Makefile
└── libft.h # Main header
Reimplement standard C functions such as:
isalpha,isdigit,isalnum,isascii,isprintstrlen,memset,bzero,memcpy,memmove,strlcpy,strlcat,toupper,tolowerstrchr,strrchr,strncmp,memchr,memcmpstrnstr,atoi,calloc,strdup
Implement higher-level string and output utilities:
substr,strjoin,strtrim,splititoa,strmapi,striteriputchar_fd,putstr_fd,putendl_fd,putnbr_fd
If all mandatory functions pass Moulinette:
ft_lstnew,ft_lstadd_front,ft_lstsize,ft_lstlastft_lstadd_back,ft_lstdelone,ft_lstclear,ft_lstiter,ft_lstmap
This project is part of the 42 Network curriculum and is subject to their academic integrity policy. You are encouraged to use it as a learning resource only.
You can read the official 42 Libft subject here:
👉 Libft Subject PDF
