Skip to content

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.

Notifications You must be signed in to change notification settings

devwithmike/libft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Libft

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.

Overview

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.

Getting Started

Prerequisites

  • GCC compiler
  • Standard Unix/Linux environment
  • Make

Installation

Clone the repository and navigate to the directory:

git clone https://github.com/mikefmeyer/libft
cd libft/

Building

Compile the library using Make:

make

This generates libft.a, a static library archive ready for linking.

Usage

Linking with Your Project

To use the library in your C programs:

  1. Include the header file in your source code:

    #include "libft.h"
  2. Compile your program with the library:

    gcc [your_main.c] [other_files.c] libft.a -o program_name
    ./program_name

Extending the Library

To add new functions to the library:

  1. Create your function implementation in a new .c file
  2. Declare the function prototype in libft.h
  3. Add the object file to the Makefile
  4. Run make to recompile

Project Contents

The library includes 80+ implementations covering the following categories:

Character Classification

Character testing functions to identify character types:

  • ft_isalpha — Check if character is alphabetic
  • ft_isdigit — Check if character is a digit
  • ft_isalnum — Check if character is alphanumeric
  • ft_isascii — Check if character is ASCII
  • ft_isprint — Check if character is printable
  • ft_tolower, ft_toupper — Case conversion

String Manipulation

Core string handling and transformation functions:

  • ft_strlen — Calculate string length
  • ft_strcpy, ft_strncpy — Copy strings
  • ft_strcat, ft_strncat — Concatenate strings
  • ft_strdup — Duplicate a string
  • ft_strcmp, ft_strncmp — Compare strings
  • ft_strchr, ft_strrchr — Locate characters in strings
  • ft_strstr, ft_strnstr — Find substrings
  • ft_strlcat — Safe string concatenation
  • ft_strrev — Reverse a string
  • ft_strmap, ft_strmapi — Apply functions to strings
  • ft_strtrim — Remove whitespace from string
  • ft_strsplit — Split string by delimiter
  • ft_strjoin — Concatenate strings with allocation
  • ft_strsub — Extract substring

String Creation & Deletion

Dynamic string allocation and cleanup:

  • ft_strnew — Create new zero-initialized string
  • ft_strdel — Free allocated string
  • ft_strclr — Clear string contents
  • ft_striter, ft_striteri — Iterate over string characters
  • ft_strequ, ft_strnequ — Compare string equality

Memory Operations

Low-level memory manipulation:

  • ft_memset — Fill memory with value
  • ft_memcpy — Copy memory area
  • ft_memmove — Move memory area (handles overlap)
  • ft_memchr — Search for byte in memory
  • ft_memcmp — Compare memory areas
  • ft_memccpy — Copy until character found
  • ft_bzero — Zero-fill memory
  • ft_memalloc — Allocate zero-initialized memory
  • ft_memdel — Free allocated memory

Conversion Functions

Convert between data types:

  • ft_atoi — Convert string to integer
  • ft_itoa — Convert integer to string
  • ft_numlen — Get length of number

Output Functions

Direct output to standard output or file descriptors:

  • ft_putchar — Write single character
  • ft_putstr — Write string
  • ft_putnbr — Write number
  • ft_putendl — Write string with newline
  • ft_putchar_fd — Write character to file descriptor
  • ft_putstr_fd — Write string to file descriptor
  • ft_putnbr_fd — Write number to file descriptor
  • ft_putendl_fd — Write string with newline to file descriptor

List Operations

Linked list structure and manipulation:

  • ft_lstnew — Create new list node
  • ft_lstadd — Add node to list
  • ft_lstdel — Delete entire list
  • ft_lstdelone — Delete single node
  • ft_lstiter — Iterate over list nodes

Utility Functions

Miscellaneous helper functions:

  • ft_swap — Swap two integers
  • ft_pwr — Calculate power
  • ft_sqrt — Calculate square root
  • ft_foreach — Apply function to array elements
  • ft_wordcount — Count words in string
  • ft_wordlen — Get word length in string
  • ft_wordcount — Count words separated by delimiter

I/O Functions

Advanced input operations:

  • get_next_line — Read file line by line (bonus function)

Helper Functions

Utility functions for memory management:

  • free_her — Free null-terminated string array
  • join_her — Join string array with delimiter

License

Created as part of WeThinkCode learning curriculum.

About

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.

Topics

Resources

Stars

Watchers

Forks