📘 libft is a custom C library implementing a collection of general‑purpose functions — many of which mirror the behavior of the standard C library — and additional utility functions that are commonly used in C programming. This project is part of the 42 School curriculum and serves as the foundation for future C projects by giving you a deep understanding of core concepts like memory manipulation, strings, and linked lists. ([GitHub][1])
- About
- Features
- Getting Started
- Usage
- Project Structure
- Compilation & Makefile
- Contributing
The goal of this project is to re‑implement and understand a broad set of C functions from scratch, without using many of the library functions provided by <string.h>, <ctype.h>, or <stdlib.h>. Once completed, this library produces a static archive libft.a which you can link to your own C programs. ([GitHub][1])
✔️ Reimplementation of standard C library functions (ft_strlen, ft_memcpy, etc.)
✔️ Additional utility functions (ft_substr, ft_split, ft_itoa, etc.)
✔️ Bonus linked list functions (ft_lstnew, ft_lstadd_front, etc.)
✔️ Designed to meet 42 norms and compile cleanly with strict flags (-Wall -Wextra -Werror) ([GitHub][1])
- A C compiler (like
gccorclang) make
-
Clone the repository:
git clone https://github.com/mohos26/libft.git cd libft -
Compile the library:
make
This produces a static library libft.a.
To use the library in your own C code:
-
Include the header in your
.cfiles:#include "libft.h"
-
Link the static library when compiling:
gcc -o my_program my_program.c -L. -lft
Replace my_program.c with your source file and adjust paths as needed.
libft/
├─ Makefile
├─ libft.h
├─ *.c # Mandatory functions
├─ *_bonus.c # Linked list bonus functions
├─ libft.a # Generated library
Typical categories of functions include:
- Character checks & conversions (
ft_isalpha,ft_toupper, …) - String manipulation (
ft_strlen,ft_strjoin,ft_strtrim, …) - Memory operations (
ft_memset,ft_memcpy, …) - File descriptor outputs (
ft_putchar_fd,ft_putnbr_fd, …) - Linked list utilities (
ft_lstnew,ft_lstadd_back, …) ([GitHub][2])
| Rule | Description |
|---|---|
make |
Build the library with mandatory functions |
make bonus |
Build including bonus (linked list) functions |
make clean |
Remove object files (*.o) |
make fclean |
Remove object files and the library (libft.a) |
make re |
Rebuild everything from scratch |
This repository is intended to reflect your personal implementation of the 42 libft project. If you choose to share improvements, bug fixes, or testing additions, feel free to open a pull request.