A custom C library implementing core functions from the C Standard Library (libc). This project was developed as part of the WeThinkCode curriculum to deepen understanding of fundamental C programming concepts and library implementation.
Libft is a collection of commonly-used C library functions, reimplemented from scratch. The project covers memory management, string manipulation, character operations, list operations, and utility functions—all essential building blocks for systems programming.
- GCC compiler
- Standard Unix/Linux environment
- Make
Clone the repository and navigate to the directory:
git clone https://github.com/mikefmeyer/libft
cd libft/Compile the library using Make:
makeThis generates libft.a, a static library archive ready for linking.
To use the library in your C programs:
-
Include the header file in your source code:
#include "libft.h"
-
Compile your program with the library:
gcc [your_main.c] [other_files.c] libft.a -o program_name ./program_name
To add new functions to the library:
- Create your function implementation in a new
.cfile - Declare the function prototype in
libft.h - Add the object file to the
Makefile - Run
maketo recompile
The library includes 80+ implementations covering the following categories:
Character testing functions to identify character types:
ft_isalpha— Check if character is alphabeticft_isdigit— Check if character is a digitft_isalnum— Check if character is alphanumericft_isascii— Check if character is ASCIIft_isprint— Check if character is printableft_tolower,ft_toupper— Case conversion
Core string handling and transformation functions:
ft_strlen— Calculate string lengthft_strcpy,ft_strncpy— Copy stringsft_strcat,ft_strncat— Concatenate stringsft_strdup— Duplicate a stringft_strcmp,ft_strncmp— Compare stringsft_strchr,ft_strrchr— Locate characters in stringsft_strstr,ft_strnstr— Find substringsft_strlcat— Safe string concatenationft_strrev— Reverse a stringft_strmap,ft_strmapi— Apply functions to stringsft_strtrim— Remove whitespace from stringft_strsplit— Split string by delimiterft_strjoin— Concatenate strings with allocationft_strsub— Extract substring
Dynamic string allocation and cleanup:
ft_strnew— Create new zero-initialized stringft_strdel— Free allocated stringft_strclr— Clear string contentsft_striter,ft_striteri— Iterate over string charactersft_strequ,ft_strnequ— Compare string equality
Low-level memory manipulation:
ft_memset— Fill memory with valueft_memcpy— Copy memory areaft_memmove— Move memory area (handles overlap)ft_memchr— Search for byte in memoryft_memcmp— Compare memory areasft_memccpy— Copy until character foundft_bzero— Zero-fill memoryft_memalloc— Allocate zero-initialized memoryft_memdel— Free allocated memory
Convert between data types:
ft_atoi— Convert string to integerft_itoa— Convert integer to stringft_numlen— Get length of number
Direct output to standard output or file descriptors:
ft_putchar— Write single characterft_putstr— Write stringft_putnbr— Write numberft_putendl— Write string with newlineft_putchar_fd— Write character to file descriptorft_putstr_fd— Write string to file descriptorft_putnbr_fd— Write number to file descriptorft_putendl_fd— Write string with newline to file descriptor
Linked list structure and manipulation:
ft_lstnew— Create new list nodeft_lstadd— Add node to listft_lstdel— Delete entire listft_lstdelone— Delete single nodeft_lstiter— Iterate over list nodes
Miscellaneous helper functions:
ft_swap— Swap two integersft_pwr— Calculate powerft_sqrt— Calculate square rootft_foreach— Apply function to array elementsft_wordcount— Count words in stringft_wordlen— Get word length in stringft_wordcount— Count words separated by delimiter
Advanced input operations:
get_next_line— Read file line by line (bonus function)
Utility functions for memory management:
free_her— Free null-terminated string arrayjoin_her— Join string array with delimiter
Created as part of WeThinkCode learning curriculum.