This activity has been created as part of the 42 curriculum by ydames.
Libft is the foundational C programming project of the 42 curriculum. Since standard C library functions are not permitted by default in most subsequent projects, the goal of this activity is to re-implement a comprehensive set of essential libc functions, alongside additional utility functions for string manipulation, file descriptor output, and linked list management.
The resulting static library (libft.a) serves as a personal toolkit that will be reused and expanded throughout future C projects. All functions are written in C in strict compliance with the 42 Norm and compiled without memory leaks or undefined behaviors.
| Part | Category | Functions |
|---|---|---|
| Part 1 | Character Checks & Conversions | ft_isalpha, ft_isdigit, ft_isalnum, ft_isascii, ft_isprint, ft_toupper, ft_tolower |
| Part 1 | String Manipulation | ft_strlen, ft_strchr, ft_strrchr, ft_strncmp, ft_strlcpy, ft_strlcat, ft_strnstr, ft_atoi |
| Part 1 | Memory Manipulation | ft_memset, ft_bzero, ft_memcpy, ft_memmove, ft_memchr, ft_memcmp |
| Part 1 | Dynamic Allocation | ft_calloc, ft_strdup |
| Part 2 | String Creation & Transform | ft_substr, ft_strjoin, ft_strtrim, ft_split, ft_itoa, ft_strmapi, ft_striteri |
| Part 2 | File Descriptor Output | ft_putchar_fd, ft_putstr_fd, ft_putendl_fd, ft_putnbr_fd |
| Part 3 | Linked Lists (t_list) |
ft_lstnew, ft_lstadd_front, ft_lstadd_back, ft_lstsize, ft_lstlast, ft_lstdelone, ft_lstclear, ft_lstiter, ft_lstmap |
The project includes a Makefile compliant with the 42 Norm (compiling with cc and the -Wall -Wextra -Werror flags without relinking) and generates libft.a at the root of the repository.
-
Clone the repository:
git clone [https://github.com/m4ss-dev/Common-Core---Libft-dd69b518-c470-4dda-8722-53db7e041016.git](https://github.com/m4ss-dev/Common-Core---Libft-dd69b518-c470-4dda-8722-53db7e041016.git) libft cd libft -
Compile the library:
make
-
Available Makefile rules:
makeormake all: Compiles the source files and createslibft.a.make clean: Removes object files (.o).make fclean: Removes object files andlibft.a.make re: Performs a full recompilation (fcleanfollowed byall).
Include "libft.h" in your C source files and link libft.a during compilation:
#include "libft.h"
int main(void)
{
ft_putendl_fd("Hello from libft!", 1);
return (0);
}Compile your program with the library:
cc -Wall -Wextra -Werror main.c libft.a -o my_program
./my_program- Linux / BSD Manual Pages (
man): Official documentation covering standardlibcbehaviors, edge cases, and prototypes (man 3 strlen,man 3 calloc,man 3 strlcat, etc.). - The C Programming Language (K&R): Reference book on pointers, memory management, and standard library design.
- 42 Norm Documentation: Official coding style and structure guidelines enforced by
norminette.
In accordance with 42's AI guidelines, AI tools were strictly used as an educational tutor (without generating ready-to-use code):
- Debugging and Edge Cases: Analyzing compiler warnings, Norminette errors, and memory edge cases (such as checking for
SIZE_MAXoverflow inft_callocorunsigned charcomparisons inft_strncmp). - Algorithmic Guidance: Step-by-step breakdown of algorithms (such as
ft_atoiand memory allocation strategies) through guided questions rather than direct answers. - Documentation: Structuring, formatting, and translating this
README.mdfile to comply with the project requirements.