10000 GitHub - valyriasteel/Libft: A foundational C library reimplementing standard functions to master memory management, string operations, and low-level programming — built as part of the 42 school curriculum.
[go: up one dir, main page]

Skip to content

A foundational C library reimplementing standard functions to master memory management, string operations, and low-level programming — built as part of the 42 school curriculum.

License

Notifications You must be signed in to change notification settings

valyriasteel/Libft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📚 Libft – A Reimplementation of Key C Standard Library Functions

Libft Build License Made with C

📑 Table of Contents

📌 Project Description

Libft is a foundational C library developed as part of the 42 school curriculum. It reimplements core functions from the C standard library and includes additional utilities for handling strings, memory, and characters.

The goal of this project is to deepen understanding of fundamental C programming by implementing widely-used functions from scratch.

🧠 This project was built to strengthen my knowledge of low-level systems programming in C. It reflects my dedication to mastering memory management and core logic at the system level.

🧩 Features Overview

The library includes a wide range of functions grouped under several categories:

🔤 String Manipulation

  • ft_strlen – Get the length of a string
  • ft_strjoin – Join two strings
  • ft_strchr – Find the first occurrence of a character in a string
  • ft_strdup – Duplicate a string
  • ft_strtrim – Trim characters from the beginning and end of a string
  • ft_substr – Extract a substring from a string
  • ft_strlcpy – Copy string with size limit
  • ft_strlcat – Concatenate strings with size limit
  • ft_strncmp – Compare strings up to n characters
  • ft_strnstr – Locate a substring in a string up to n characters
  • ft_strrchr – Find the last occurrence of a character in a string
  • ft_strmapi – Apply a function to each character and return new string
  • ft_striteri – Apply a function to each character by index

🖥️ Memory Management

  • ft_memset – Fill memory with a constant byte
  • ft_memcpy – Copy memory area
  • ft_memmove – Move memory area safely
  • ft_calloc – Allocate and zero-initialize memory
  • ft_bzero – Zero out a memory area
  • ft_memchr – Scan memory for a byte
  • ft_memcmp – Compare memory areas

🔣 Character Checks & Conversions

  • ft_isalnum – Check for alphanumeric character
  • ft_isalpha – Check for alphabetic character
  • ft_isascii – Check for ASCII character
  • ft_isdigit – Check for digit
  • ft_isprint – Check for printable character
  • ft_tolower – Convert character to lowercase
  • ft_toupper – Convert character to uppercase

🖊️ I/O Functions

  • ft_putchar_fd – Output a character to a file descriptor
  • ft_putendl_fd – Output a string followed by newline to a file descriptor
  • ft_putnbr_fd – Output an integer to a file descriptor
  • ft_putstr_fd – Output a string to a file descriptor

🧰 Other Utilities

  • ft_atoi – Convert string to integer
  • ft_itoa – Convert integer to string
  • ft_split – Split a string by delimiter

⚙️ Compilation

Run the following commands to build the project:

git clone https://github.com/valyriasteel/libft.git
cd libft
make

This will generate libft.a, the static archive that you can link against in your C projects.

Other useful commands:

make clean   # Remove object files
make fclean  # Remove all compiled files including libft.a
make re      # Rebuild from scratch

🚀 Usage

Include the header in your source files:

#include "libft.h"

Then compile your project with:

cc main.c -L. -lft -o program

If your file structure is different:

cc src/main.c -Llibft -lft -Ilibft -o program

🧪 You can create a simple main.c to test the functions, or use your own test framework.

💡 Example

#include "libft.h"
#include <stdio.h>

int main() {
    char *str = "Hello, Libft!";
    size_t len = ft_strlen(str);
    printf("String length: %zu\n", len);
    return 0;
}

Output

String length: 13

📁 Project Structure

The layout below is simplified for clarity. All source files are located in the root directory.

libft/
├── ft_*.c            # All source files (e.g. ft_strlen.c, ft_memcpy.c, etc.)
├── libft.h           # Main header file
├── Makefile          # Build script
└── README.md         # Documentation

📜 License

This project is licensed under the MIT License. See LICENSE for details.

📬 Contact

For questions, issues, or contributions:

📝 This project and its documentation are written in English to ensure accessibility for a global audience.


Keywords: libft, custom C library, 42 school project, memory management, string functions, C programming

About

A foundational C library reimplementing standard functions to master memory management, string operations, and low-level programming — built as part of the 42 school curriculum.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0