Skip to content

a-i-nur/libft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Libft

libft is the first foundational C project at 42 School. This repository is my first project from the 42 School Common Core Curriculum (Circle 0).

Subject Requirements (from libft project)

Item Requirement
Program name libft.a
Turn-in files Makefile, libft.h, ft_*.c
Makefile rules NAME, all, clean, fclean, re, bonus
Allowed external functions malloc, free, write
Libft authorized Yes
Goal Recode standard libc-style utilities and add extra reusable functions

Project Scope

This project includes:

  • reimplemented libc-like functions (string, memory, character checks, conversions)
  • additional utility functions required by the subject
  • bonus linked-list API (t_list)

Current scope in this repository:

  • 23 libc-style reimplemented functions
  • 11 libft-specific functions
  • 9 bonus linked-list functions

Build

make        # mandatory part
make bonus  # mandatory + linked-list bonus
make clean
make fclean
make re

The build output is a static library: libft.a.

1) Libc-Style Functions

Function Description Original library
ft_isalpha Check whether a character is alphabetic. isalpha (<ctype.h>)
ft_isdigit Check whether a character is a digit. isdigit (<ctype.h>)
ft_isalnum Check whether a character is alphanumeric. isalnum (<ctype.h>)
ft_isascii Check whether value is in ASCII range. isascii (<ctype.h>, extension)
ft_isprint Check whether a character is printable. isprint (<ctype.h>)
ft_strlen Return string length. strlen (<string.h>)
ft_memset Fill memory with a byte value. memset (<string.h>)
ft_bzero Zero out a memory block. bzero (<strings.h>, legacy)
ft_memcpy Copy memory (no overlap support). memcpy (<string.h>)
ft_memmove Copy memory (overlap-safe). memmove (<string.h>)
ft_strlcpy Size-bounded string copy. strlcpy (BSD libc)
ft_strlcat Size-bounded string concatenation. strlcat (BSD libc)
ft_toupper Convert character to uppercase. toupper (<ctype.h>)
ft_tolower Convert character to lowercase. tolower (<ctype.h>)
ft_strchr Find first occurrence of a character in a string. strchr (<string.h>)
ft_strrchr Find last occurrence of a character in a string. strrchr (<string.h>)
ft_strncmp Compare two strings up to n chars. strncmp (<string.h>)
ft_memchr Find a byte in memory. memchr (<string.h>)
ft_memcmp Compare two memory areas. memcmp (<string.h>)
ft_strnstr Find substring within size limit. strnstr (BSD libc)
ft_atoi Convert string to int. atoi (<stdlib.h>)
ft_calloc Allocate and zero-initialize memory. calloc (<stdlib.h>)
ft_strdup Duplicate a string into new memory. strdup (POSIX)

2) Libft-Specific Functions

Function Description Original library
ft_substr Extract a substring by start index and length. No direct libc equivalent
ft_strjoin Join two strings into a new one. No direct libc equivalent
ft_strtrim Trim a set of characters from both string ends. No direct libc equivalent
ft_split Split a string by delimiter into string array. No direct libc equivalent
ft_itoa Convert int to string. No direct libc equivalent
ft_strmapi Build new string by applying function to each char. No direct libc equivalent
ft_striteri Apply function in-place to each char. No direct libc equivalent
ft_putchar_fd Write one character to file descriptor. No direct libc equivalent
ft_putstr_fd Write string to file descriptor. No direct libc equivalent
ft_putendl_fd Write string + newline to file descriptor. No direct libc equivalent
ft_putnbr_fd Write integer to file descriptor. No direct libc equivalent

3) Bonus Functions (Linked List)

Function Description Original library
ft_lstnew Create a new list node (t_list). No direct libc equivalent
ft_lstadd_front Add node to beginning of list. No direct libc equivalent
ft_lstsize Count nodes in list. No direct libc equivalent
ft_lstlast Get last node of list. No direct libc equivalent
ft_lstadd_back Add node to end of list. No direct libc equivalent
ft_lstdelone Delete one node using del callback. No direct libc equivalent
ft_lstclear Delete and clear entire list. No direct libc equivalent
ft_lstiter Iterate over list and apply function to content. No direct libc equivalent
ft_lstmap Map list into new list with transform function. No direct libc equivalent

Project Structure

Skills Developed in This Project

This project develops practical low-level C skills:

  • memory management (malloc, free) and pointer safety
  • robust handling of edge cases in string and memory operations
  • writing reusable APIs and organizing code into a static library
  • working with a C header (libft.h): prototypes, types, and interface contracts
  • working with Makefile rules (all, clean, fclean, re, bonus) and static archive generation
  • implementing and using a custom singly linked list API (t_list) with creation, traversal, mapping, and cleanup

Key Achievements

  • Built a reusable static C library (libft.a) from scratch with consistent API design.
  • Implemented 43 core utility functions covering strings, memory, conversion, output, and linked lists.
  • Structured the project with clear separation of interface (libft.h), implementation (ft_*.c), and build pipeline (Makefile).
  • Completed both mandatory and bonus scopes, including a full singly linked list module.

How This Maps to Real-World Engineering

  • Code reliability: careful edge-case handling and defensive memory usage translate directly to production C/C++ code.
  • Maintainability: header-driven interfaces and modular source files mirror real library and service architecture.
  • Build discipline: Makefile targets and static library packaging reflect CI/CD and reproducible build practices.
  • Data structure fluency: linked list operations build a foundation for more advanced algorithmic and systems tasks.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors