Libft is a custom C library developed as part of the 42 curriculum.
It reimplements standard C library functions and introduces additional utilities for memory management, string handling, and linked lists.
The goal is to strengthen understanding of low-level programming, pointers, and data structures by building a reusable toolkit from scratch.
- Language: C
- Output:
libft.a(static library) - Purpose: Provide a foundation of essential functions for use in future 42 projects
- Skills Learned:
- Memory allocation and management
- String and character manipulation
- Linked list operations
- Makefile usage and compilation
- Debugging and testing
Libft includes implementations of:
-
Libc functions
Reimplementations of standard functions like:strlen,strcpy,memcpy,atoi,isdigit,toupper, etc.
-
Additional functions
Helpers for string manipulation, memory handling, and conversions:ft_substr,ft_strjoin,ft_split,ft_itoa, etc.
-
Linked list utilities (Bonus part)
Functions to create, traverse, and manipulate linked lists (t_list):ft_lstnew,ft_lstadd_front,ft_lstmap,ft_lstclear, etc.
To compile the library:
makeThis will generate:
libft.a
Cleaning and rebuilding:
make clean # Remove object files
make fclean # Remove object files + libft.a
make re # Rebuild everythingYou can include libft in your C projects by linking the compiled library:
gcc main.c -L. -lft -o mainOr directly:
gcc main.c libft.a -o mainInclude the header file in your source:
#include "libft.h"
Example:
#include "libft.h"
#include <stdio.h>
int main(void)
{
char str[] = "Hello, Libft!";
printf("Length: %zu\n", ft_strlen(str));
return 0;
}
.
├── Makefile
├── libft.h
├── ft_*.c
└── libft.a
- Memory:
ft_memset,ft_bzero,ft_memcpy,ft_calloc, etc. - Strings:
ft_strlen,ft_strdup,ft_strjoin,ft_split, etc. - Characters:
ft_isalpha,ft_toupper, etc. - Linked Lists:
ft_lstnew,ft_lstadd_front,ft_lstmap, etc.
RIDA SBAA 📧 rsbaa@student.1337.ma GitHub Repository