A custom C standard-library implementation from the 42 curriculum, packaged as a static library (libft.a).
This project provides:
- Core character, string, memory, and conversion utilities.
- File-descriptor output helpers.
- Bonus singly linked-list helpers (
t_list).
libft/
├── Makefile
├── libft.h
├── ft_*.c
└── ft_lst*_bonus.c
Build the main library:
makeBuild bonus objects and append them to the library:
make bonusClean objects:
make cleanClean everything (objects + libft.a):
make fcleanRebuild from scratch:
make reAfter make, you get:
libft.a— static archive containing the compiled functions.
#include "libft.h"cc -Wall -Wextra -Werror main.c libft.a -o appOr link from parent directory:
cc -Wall -Wextra -Werror main.c -L./libft -lft -I./libft -o appft_isalphaft_isdigitft_isalnumft_isasciift_isprintft_toupperft_tolower
ft_strlenft_strchrft_strrchrft_strncmpft_strnstrft_strdupft_strlcpyft_strlcatft_substrft_strjoinft_strtrimft_splitft_strmapift_striteri
ft_memsetft_bzeroft_memcpyft_memmoveft_memchrft_memcmpft_calloc
ft_atoift_itoa
ft_putchar_fdft_putstr_fdft_putendl_fdft_putnbr_fd
Defined in libft.h:
typedef struct s_list
{
void *content;
struct s_list *next;
} t_list;Implemented helpers:
ft_lstnewft_lstadd_frontft_lstadd_backft_lstsizeft_lstlastft_lstdeloneft_lstclearft_lstiter
ft_lstmap_bonus.cexists but currently contains only a declaration (no function body).Makefilebonus sources (BSRC) currently do not includeft_lstmap_bonus.libft.hcurrently does not expose aft_lstmapprototype.
So in its current state, ft_lstmap is not part of the usable API.
#include "libft.h"
#include <unistd.h>
int main(void)
{
char **parts = ft_split("42-libft-project", '-');
if (parts)
{
ft_putendl_fd(parts[0], 1); // 42
ft_putendl_fd(parts[1], 1); // libft
ft_putendl_fd(parts[2], 1); // project
}
return (0);
}Compile example:
cc -Wall -Wextra -Werror main.c -L. -lft -I. -o demo