Skip to content

mobouifr/Libft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This project has been created as part of the 42 curriculum by mobouifr.

LIBFT

A foundational C static library that reimplements core libc behaviors and essential string/memory helpers.

Language Build Norm

What Is This?

libft is a custom static library (libft.a) containing reimplemented libc-style utilities and additional helper functions used throughout the 42 curriculum.

This repository includes character checks, memory functions, string utilities, conversion helpers, dynamic string constructors, split/trim helpers, and file-descriptor output functions. Everything is organized as ft_*.c files with declarations in libft.h.

Technically, it is interesting because it forces precise handling of pointer arithmetic, allocation patterns, boundary conditions, and API behavior compatibility with familiar C functions.

Build your own standard tools first, then build everything else on top of them.

How It Works

The project compiles each source file to an object (.o) with cc -Wall -Werror -Wextra, then archives changed objects into libft.a using ar -rc.

ft_*.c  --(cc -c)-->  ft_*.o  --(ar -rc)-->  libft.a

At code level, many higher-level functions are layered on core helpers already present in the library (for example: ft_strtrim uses ft_strlen, ft_strchr, and ft_strdup; ft_strjoin uses ft_strdup for null-side fallback).

Features

Feature Status Notes
Libc-style reimplementations (part 1 set) Present as dedicated ft_*.c files and declared in libft.h.
Additional string/allocation/output helpers (part 2 set) All listed part-2 source files are present and compile into the archive.
Static library archive generation ar -rc produces libft.a from compiled object files.
Bonus linked-list API No *_bonus.c/*_bonus.h files in repository.
Verified function-by-function status
Function Status Notes
ft_isalpha ASCII letter range checks, returns 1/0.
ft_isdigit ASCII digit range checks, returns 1/0.
ft_isalnum Combines alpha and digit checks, returns 1/0.
ft_isascii Checks 0..127, returns 1/0.
ft_isprint Checks printable ASCII 32..126, returns 1/0.
ft_strlen Counts bytes until \0.
ft_memset Byte fill loop over len.
ft_bzero Zeroes n bytes via byte loop.
ft_memcpy Copies forward; explicit NULL/NULL guard and same-pointer early return.
ft_memmove Handles overlap with backward copy when needed.
ft_strlcpy Copies up to dstsize - 1, always null-terminates when dstsize > 0.
ft_strlcat Appends into remaining buffer space, returns attempted total length.
ft_toupper Lowercase ASCII to uppercase.
ft_tolower Uppercase ASCII to lowercase.
ft_strchr Finds first match including search for terminating \0.
ft_strrchr Walks from end to find last occurrence.
ft_strncmp Byte comparison up to n.
ft_memchr Scans memory for byte match within n.
ft_memcmp Bytewise memory comparison.
ft_strnstr Bounded substring search, includes needle == "" handling.
ft_atoi Trims ASCII whitespace, parses sign and digits.
ft_calloc partial Allocates and zeroes, but overflow check uses 0xffffffff threshold.
ft_strdup Allocates and copies full C-string.
ft_substr partial Handles start >= strlen with empty duplicate; contains dead trailing return (0);.
ft_strjoin Concatenates strings; also supports single-null fallback via ft_strdup.
ft_strtrim Trims start/end chars contained in set.
ft_split Allocates token array, per-token allocation, cleanup-on-failure helper.
ft_itoa Handles positive/negative conversion and writes digits into allocated output string.
ft_strmapi Allocates mapped string from callback (index, char).
ft_striteri In-place callback application with null checks.
ft_putchar_fd Writes one char when fd != -1.
ft_putstr_fd Writes full string when s != NULL and fd != -1.
ft_putendl_fd ft_putstr_fd-style write plus newline.
ft_putnbr_fd Handles 0, INT_MIN, negatives, and digit emission via local buffer.

Project Structure

.
├── .git/ ← Git metadata directory
├── Makefile ← Build rules for objects and libft.a
├── README.md ← Project documentation
├── libft.h ← Public header with all function prototypes and includes
├── ft_atoi.c ← ASCII-to-int conversion
├── ft_bzero.c ← Zero memory bytes
├── ft_calloc.c ← Allocate + zero-initialize memory
├── ft_isalnum.c ← Alphanumeric classification
├── ft_isalpha.c ← Alphabetic classification
├── ft_isascii.c ← ASCII-range classification
├── ft_isdigit.c ← Digit classification
├── ft_isprint.c ← Printable-character classification
├── ft_itoa.c ← Int-to-string conversion
├── ft_memchr.c ← Search byte in memory region
├── ft_memcmp.c ← Compare memory regions
├── ft_memcpy.c ← Copy memory (non-overlap style)
├── ft_memmove.c ← Copy memory with overlap safety
├── ft_memset.c ← Fill memory with a byte
├── ft_putchar_fd.c ← Write one char to a file descriptor
├── ft_putendl_fd.c ← Write string + newline to a file descriptor
├── ft_putnbr_fd.c ← Write integer to a file descriptor
├── ft_putstr_fd.c ← Write string to a file descriptor
├── ft_split.c ← Split string by delimiter into allocated array
├── ft_strchr.c ← Find first character occurrence
├── ft_strdup.c ← Duplicate string to new allocation
├── ft_striteri.c ← In-place per-char iteration callback
├── ft_strjoin.c ← Concatenate two strings into new allocation
├── ft_strlcat.c ← Size-bounded append
├── ft_strlcpy.c ← Size-bounded copy
├── ft_strlen.c ← String length
├── ft_strmapi.c ← Mapped copy via callback
├── ft_strncmp.c ← Compare two strings up to n bytes
├── ft_strnstr.c ← Bounded substring search
├── ft_strrchr.c ← Find last character occurrence
├── ft_strtrim.c ← Trim character set from both ends
├── ft_substr.c ← Extract substring into new allocation
├── ft_tolower.c ← Upper-to-lower ASCII conversion
└── ft_toupper.c ← Lower-to-upper ASCII conversion

Getting Started

Build Commands (verified in this repository)

make fclean
make

Makefile Rules

Rule Verified behavior
all Triggers $(NAME) build path.
$(NAME) Runs ar -rc libft.a $? after object compilation.
clean Removes object files listed in $(OBJ).
fclean Runs clean then removes libft.a.
re Runs fclean then all.

Build Configuration

Key Value
Compiler cc
Flags -Wall -Werror -Wextra
Archive tool ar -rc
Output libft.a

Resources

Resource Why it matters here
42 Libft subject (v19.2) Defines expected function set and constraints for this project.
man pages for libc functions Baseline behavior references for reimplementations.
GNU Make manual Useful for understanding pattern rules (.c.o) and rebuild logic.

About

A custom C static library from the 42 curriculum, reimplementing core libc functions plus practical string, memory, and file-descriptor utilities.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors