This project has been created as part of the 42 curriculum by fcamasa.
I could say that this project is like our own tool box that helps us to make all future projects possible by using all the tools that we have created inside this project, our own tools kit.
Libft is a from-scratch reimplementation of key functions from the C standard library (libc), extended with additional utilities for string manipulation, memory management, and linked lists.
The primary goal is to understand how memory management (malloc, free), pointers, and data structures work at a low level in C — without relying on native functions. This forces manual handling of buffer overflows, memory leaks, and undefined behaviors. The library serves as the code foundation for all subsequent 42 cursus projects such as get_next_line, ft_printf, and minishell.
Reimplementations of standard tools from the C library.
Character checks — <ctype.h>
| Function | Description |
|---|---|
ft_isalpha |
Returns true if the character is alphabetic |
ft_isdigit |
Returns true if the character is a digit |
ft_isalnum |
Returns true if the character is alphanumeric |
ft_isascii |
Returns true if the character is in the ASCII table |
ft_isprint |
Returns true if the character is printable |
ft_toupper |
Converts a lowercase letter to uppercase |
ft_tolower |
Converts an uppercase letter to lowercase |
Memory management — <string.h> / <stdlib.h>
| Function | Description |
|---|---|
ft_memset |
Fills a memory block with a specific byte |
ft_bzero |
Sets a memory block to zero |
ft_memcpy |
Copies a memory region from source to destination |
ft_memmove |
Same as memcpy but handles overlapping regions safely |
ft_memchr |
Searches for a byte within a memory block |
ft_memcmp |
Compares two memory blocks byte by byte |
ft_calloc |
Allocates zero-initialized memory dynamically |
String manipulation — <string.h>
| Function | Description |
|---|---|
ft_strlen |
Returns the length of a string |
ft_strlcpy |
Copies a string with guaranteed null-termination |
ft_strlcat |
Concatenates two strings with guaranteed null-termination |
ft_strchr |
Finds the first occurrence of a character in a string |
ft_strrchr |
Finds the last occurrence of a character in a string |
ft_strncmp |
Compares two strings up to n characters |
ft_strnstr |
Locates a substring within a string, up to n characters |
ft_strdup |
Duplicates a string into a newly allocated memory region |
ft_atoi |
Converts a numeric string to a signed integer |
Custom utilities not found in the standard library.
| Function | Description |
|---|---|
ft_substr |
Extracts a substring from a string at a given index and length |
ft_strjoin |
Concatenates two strings into a new allocated string |
ft_strtrim |
Removes a set of characters from both ends of a string |
ft_split |
Splits a string into an array of strings using a delimiter |
ft_itoa |
Converts an integer to its string representation |
ft_strmapi |
Applies a function to each character of a string (returns new string) |
ft_striteri |
Applies a function to each character of a string (in place) |
ft_putchar_fd |
Writes a character to a file descriptor |
ft_putstr_fd |
Writes a string to a file descriptor |
ft_putendl_fd |
Writes a string followed by a newline to a file descriptor |
ft_putnbr_fd |
Writes an integer to a file descriptor |
Functions for managing the t_list dynamic data structure.
| Function | Description |
|---|---|
ft_lstnew |
Creates a new list node |
ft_lstadd_front |
Inserts a node at the beginning of the list |
ft_lstadd_back |
Inserts a node at the end of the list |
ft_lstsize |
Returns the number of nodes in the list |
ft_lstlast |
Returns the last node of the list |
ft_lstdelone |
Frees a single node using a custom delete function |
ft_lstclear |
Frees the entire list using a custom delete function |
ft_lstiter |
Applies a function to the content of each node |
ft_lstmap |
Applies a function to each node and returns a new list |
git clone https://github.com/fcamasa/libft.git
cd libft
makeThis produces libft.a, the static library archive.
Copy libft.a and libft.h into your project, then include the header and link at compile time:
#include "libft.h"gcc main.c -L. -lft -I. -o my_program| Rule | Description |
|---|---|
make / make all |
Compiles source files and builds libft.a |
make clean |
Removes intermediate .o files |
make fclean |
Removes .o files and libft.a |
make re |
Full rebuild from scratch |
| Resource | Description |
|---|---|
| Linux Man Pages | Official reference for standard libc function behavior |
| GNU C Library Docs | Deep technical reference for core library design |
| GeeksforGeeks — C | Guides on pointers, strings, and dynamic memory |
| Francinette | Popular 42 tester for Libft — catches edge cases before evaluation |
AI tools were used in two specific areas of this project:
- Understanding functions — Used to clarify the expected behavior of certain standard libc functions, cross-referencing man pages with practical explanations to ensure correct reimplementation.
- Debugging — Used to help identify the root cause of unexpected behaviors, memory errors, and edge cases during development.
- Visual edtiting - Used for visual editing of my Makefile content ,
fcamasa — 42 student