This project has been created as part of the 42 curriculum by aalemami.
Custom C Standard Library Implementation
This project was created as part of the 42 curriculum. The goal is to build a custom C library called libft, providing reimplementations of standard C library functions alongside custom utility routines used in subsequent 42 projects.
The library consists of four main components:
- Part 1 - Libc Functions: Reimplementations of standard C library functions (
ft_strlen,ft_memset,ft_bzero,ft_memcpy,ft_memmove,ft_strlcpy,ft_strlcat,ft_toupper,ft_tolower,ft_strchr,ft_strrchr,ft_strncmp,ft_memchr,ft_memcmp,ft_strnstr,ft_atoi,ft_calloc,ft_strdup). - Part 2 - Additional Functions: Common string and utility functions (
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). - Part 3 - Linked Lists: Singly linked list manipulation utilities (
ft_lstnew,ft_lstadd_front,ft_lstsize,ft_lstlast,ft_lstadd_back,ft_lstdelone,ft_lstclear,ft_lstiter,ft_lstmap). - Part 4 - ft_printf: Integrated formatted output print engine.
Clone the repository:
git clone https://github.com/ali-alemami/libft.git
cd libftCompile the static archive libft.a using make:
makeAdditional targets:
make clean # Remove object files
make fclean # Remove object files and libft.a
make re # Rebuild from scratchInclude the header file in your C source and link libft.a:
#include "libft.h"
int main(void)
{
ft_putstr_fd("Hello 42!\n", 1);
return (0);
}Compile with:
cc main.c -L. -lft -o my_program- Linux man pages (e.g.
man 3 strlen,man 3 memset) - C Programming: Makefiles by Barry Brown
AI tools were used for code review and syntax clarification regarding:
- Edge-case handling in memory operations (
ft_memmoveoverlap detection). - Makefile dependency rules and static library archiving (
ar rcs).