libft

Libft is a foundational project developed as part of the 42 School curriculum, aimed at creating a custom C library of standard functions. It focuses on reimplementing common C functions, memory management, string manipulation, and linked lists, helping students build a solid base in low-level programming and modular code design.

GitHub
0
0
0

Last updated

April 07, 2026

Libft

Libft is a C library developed as part of the curriculum at 42 School. It reimplements and extends common libc-style utilities—memory, strings, linked lists, formatted output, and more—as a reusable static library for later projects.

Usage

Prerequisites

Clone the repository to your local machine using the following command in the terminal.

sh
git clone https://github.com/milandekruijf/libft.git && cd libft

Compiling

From the project root, build the static library:

sh
make

Compiles with cc using -Wall, -Wextra, and -Werror by default (headers from include/).

To build without those warning flags, set STRICT=1:

sh
make STRICT=1

To compile with AddressSanitizer (useful when debugging your own code that uses the library), set TEST=1:

sh
make TEST=1

The archive is written to out/libft.a with object files under out/obj/.

Using the library

Link your program against libft.a and add the include path for libft.h:

sh
cc -Wall -Wextra -Werror -I include your_main.c -L out -lft -o your_program

Include the header in your sources:

c
#include "libft.h"

Cleaning

  • make clean — remove object files under out/obj/
  • make fclean — remove the entire out/ directory
  • make re — run fclean then all

Features

Libft provides helpers grouped roughly as follows.

Character and type checks

  • Classification: ft_isalpha, ft_isdigit, ft_isalnum, ft_isascii, ft_isprint, ft_isupper, ft_islower, ft_isgraph, ft_iscntrl, ft_isblank, ft_isspace, ft_isxdigit
  • Case conversion: ft_tolower, ft_toupper

Memory

  • ft_memset, ft_bzero, ft_memcpy, ft_memmove, ft_memchr, ft_memcmp, ft_calloc

Strings

  • Length and safe copying: ft_strlen, ft_strlcpy, ft_strlcat, ft_strcpy, ft_strncpy, ft_strcat, ft_strncat
  • Search and compare: ft_strchr, ft_strrchr, ft_strncmp, ft_strcmp, ft_strnstr, ft_strstr
  • Allocation and mutation: ft_strdup, ft_strndup, ft_strdupv, ft_strnew, ft_strjoin, ft_strtrim, ft_strsub, ft_strsplit, ft_strrev, ft_strmapi, ft_striteri, ft_strlwr, ft_strupr
  • Checks: ft_strisnum, ft_strislwr, ft_strisupr, ft_strisprint, ft_strisalpha
  • Word length helper: ft_wrdlen

Numbers and conversion

  • ft_abs, ft_atoi, ft_atol, ft_itoa, ft_uitoa, ft_digitlen, ft_digittoc, ft_ptox, ft_uitox

Linked lists (t_list)

  • ft_lstnew, ft_lstprepend, ft_lstappend, ft_lstsize, ft_lstclear, ft_lstdelone, ft_lstiter, ft_lstlast, ft_lstmap

Output and I/O

  • ft_putc, ft_puts, ft_puti (file-descriptor based)
  • ft_printf — formatted output supporting %c, %s, %p, %d, %i, %u, %x, %X, and %%
  • ft_getline — read a line from a file descriptor (BUFFER_SIZE defaults in libft.h; adjust as needed)

Acknowledgements

  • 42: The educational institution that inspired and supported the development of this project.
  • Codam: The partner school of 42 in the Netherlands, where the project was developed.