Custom C library implemented as part of the 42 cursus.
The goal of this project is to recreate a subset of the standard C library functions, plus a few extra utilities, and bundle them into a reusable static library: libft.a.
School: 42 Beirut Project: Libft
Language: C
In libft, you re-implement low-level functions for:
- character and string handling
- memory management
- conversions
- basic linked list utilities (bonus)
This library will be reused in many later 42 projects, so the focus is on:
- writing clean, reliable C code
- respecting the 42 Norm
- understanding pointers, memory, and edge cases
Update this list according to what you actually implemented.
Functions for:
- Character checks & transforms
ft_isalpha,ft_isdigit,ft_isalnum,ft_isascii,ft_isprintft_toupper,ft_tolower
- Strings
ft_strlen,ft_strlcpy,ft_strlcatft_strchr,ft_strrchr,ft_strncmp,ft_strnstrft_strdup
- Memory
ft_memset,ft_bzeroft_memcpy,ft_memmoveft_memchr,ft_memcmp
- Allocation & conversion
ft_callocft_atoi
More useful helpers, for example:
- String creation & transformation:
ft_substr,ft_strjoin,ft_strtrim,ft_split,ft_strmapi,ft_striteri - Number & file descriptor utilities:
ft_itoa,ft_putchar_fd,ft_putstr_fd,ft_putendl_fd,ft_putnbr_fd
If you compiled with make bonus, the library also includes:
t_liststructure- List manipulation:
ft_lstnew,ft_lstadd_front,ft_lstadd_backft_lstsize,ft_lstlastft_lstdelone,ft_lstclearft_lstiter,ft_lstmap
.
├── Makefile
├── libft.h
├── *.c # implementation files
├── bonus/*.c # (optional) bonus list functions
└── README.md
Clone the repository and build:
git clone https://github.com/M677871/Libft.git
cd Libft
# Build mandatory part
make
# Build bonus part (if implemented)
make bonus
# Clean object files
make clean
# Remove objects + libft.a
make fclean
# Rebuild from scratch
make reAfter make, you should have:
libft.a # static library
-
Copy
libft.aandlibft.hinto your project, or add this repo as a submodule. -
Include the header in your C files:
#include "libft.h"
-
Compile and link with
libft.a:gcc -Wall -Wextra -Werror main.c libft.a -o my_program
#include "libft.h"
#include <stdio.h>
int main(void)
{
const char *s = "Hello, libft!";
size_t len = ft_strlen(s);
printf("Length: %zu\n", len);
return 0;
}You can test the library with your own mains or with external testers such as
Tripouille/libftTester:
# inside the tester directory, with LIBFT_PATH set correctly
make m # mandatory tests
make b # bonus tests
make a # all testsDon’t forget to also:
- run Norminette on
.cand.hfiles - check behavior on edge cases (NULL, empty strings, overflows, etc.)
Working on libft helps to:
- understand how standard C functions work internally
- practice pointer arithmetic and memory management
- learn to debug segmentation faults and undefined behavior
- get comfortable with 42’s Norm and project workflow
This project is part of the 42 curriculum.
You can reuse this code in your own 42 projects as allowed by the school’s rules.
- Login:
M677871 - GitHub: @M677871