This project has been created as part of the 42 curriculum by ahideo-k.
Libft is the first core project of the 42 Common Core. Its objective is to recreate a subset of the C Standard Library while implementing additional utility functions that will be reused throughout the curriculum.
This project reinforces fundamental concepts of the C language, including:
- Memory management
- Pointer manipulation
- String handling
- Character classification
- Linked lists
- Modular programming
- Static libraries
- Defensive programming
The final result is a static library (libft.a) containing reusable functions that serve as the foundation for future projects such as get_next_line, ft_printf, so_long, pipex, push_swap, and many others.
The library is divided into three main parts.
Reimplementation of standard C library functions without relying on the original implementations.
- ft_isalpha
- ft_isdigit
- ft_isalnum
- ft_isascii
- ft_isprint
- ft_toupper
- ft_tolower
- ft_strlen
- ft_strlcpy
- ft_strlcat
- ft_strchr
- ft_strrchr
- ft_strncmp
- ft_strnstr
- ft_strdup
- ft_memset
- ft_bzero
- ft_memcpy
- ft_memmove
- ft_memchr
- ft_memcmp
- ft_calloc
- ft_atoi
Utility functions frequently used in later projects.
- ft_substr
- ft_strjoin
- ft_strtrim
- ft_split
- ft_itoa
- ft_strmapi
- ft_striteri
- ft_putchar_fd
- ft_putstr_fd
- ft_putendl_fd
- ft_putnbr_fd
Implementation of a generic singly linked list.
- ft_lstnew
- ft_lstadd_front
- ft_lstsize
- ft_lstlast
- ft_lstadd_back
- ft_lstdelone
- ft_lstclear
- ft_lstiter
- ft_lstmap
.
├── Makefile
├── libft.h
├── *.c
└── README.md
The project generates the static library:
libft.a
git clone https://github.com/Andre-Kikuchi/libft.git
cd libftCompile the library:
makeClean object files:
make cleanRemove object files and the library:
make fcleanRebuild everything:
make reInclude the header:
#include "libft.h"Compile your project linking against the library:
cc main.c libft.aExample:
#include "libft.h"
int main(void)
{
ft_putendl_fd("Hello, Libft!", 1);
return (0);
}This project follows the requirements established by the 42 subject.
- Written entirely in C
- Compiled with
cc - Flags:
-Wall-Wextra-Werror
- No global variables
- Helper functions declared as
staticwhenever appropriate - Static library generated using
ar - Code compliant with the 42 Norm
Through this project I practiced:
- Memory allocation with
malloc - Safe memory manipulation
- Pointer arithmetic
- String processing
- Defensive programming
- Modular software design
- Static libraries
- Linked list manipulation
- Writing reusable code
- The C Programming Language — Brian W. Kernighan & Dennis M. Ritchie
- Linux Manual Pages (man)
- Understanding and Using C Pointers-O'Reilly Media (2013) - Richard Reese
- Linked List in C - GeeksforGeeks
- GNU C Library Documentation
Useful websites:
Artificial Intelligence was used only as a learning support tool.
Specifically, it was used to:
- clarify concepts about pointer manipulation;
- review edge cases;
- better understand the behavior of standard C library functions;
- improve documentation.
All code was designed, implemented, tested, debugged and understood before submission.
This project was developed as part of the 42 curriculum and is intended for educational purposes.