Libft42
This C library includes 40+ utility functions and features a Makefile to automate compilation generating both static (.a) and shared (.so) libraries.
Install / Use
/learn @exoks/Libft42README
Libft42
This project is a C language library that includes over 40 utility functions, designed to enhance standard functionality. It features a Makefile that automates the compilation process, generating both a static (.a) and shared (.so) library for seamless integration into various projects.
Available Functions
Memory Management
ft_bzero– Sets a memory block to zeroft_calloc– Allocates and initializes memoryft_memccpy– Copies memory until a specific byte is encounteredft_memchr– Locates a byte in a memory blockft_memcmp– Compares memory blocksft_memmove– Moves memory safely, even with overlapping regionsft_memset– Fills memory with a specified byte
String Manipulation
ft_strcat– Concatenates two stringsft_strchr– Locates a character in a stringft_strcmp– Compares two stringsft_strdup– Duplicates a stringft_striteri– Applies a function to each character of a string (indexed)ft_strjoin– Concatenates two strings with memory allocationft_strlcat– Concatenates strings with a size limitft_strlcpy– Copies a string with a size limitft_strlen– Calculates the length of a stringft_strmapi– Applies a function to each character of a stringft_strncmp– Compares two strings up toncharactersft_strnstr– Finds a substring within a string (bounded)ft_strrchr– Finds the last occurrence of a character in a stringft_strtrim– Trims specific characters from both ends of a stringft_substr– Extracts a substring from a stringft_split– Splits a string into an array of substringsft_atoi– Converts a string to an integerft_itoa– Converts an integer to a string
Character Classification & Conversion
ft_isalnum– Checks if a character is alphanumericft_isalpha– Checks if a character is alphabeticft_isascii– Checks if a character belongs to the ASCII setft_isdigit– Checks if a character is a digitft_isprint– Checks if a character is printableft_tolower– Converts an uppercase character to lowercaseft_toupper– Converts a lowercase character to uppercase
Linked List Operations
ft_lstadd_back– Adds a node at the end of a listft_lstadd_front– Adds a node at the beginning of a listft_lstclear– Clears an entire linked listft_lstdelone– Deletes a single node from a listft_lstiter– Iterates over a linked list and applies a functionft_lstlast– Retrieves the last node in a linked listft_lstmap– Applies a function to each node and creates a new listft_lstnew– Creates a new linked list nodeft_lstsize– Counts the number of nodes in a list
File I/O Operations
ft_putchar_fd– Writes a character to a file descriptorft_putendl_fd– Writes a string followed by a newline to a file descriptorft_putnbr_fd– Writes an integer to a file descriptorft_putstr_fd– Writes a string to a file descriptorget_next_line– Reads a line from a file descriptor
Building the Library
Libft supports both static and shared library generation through the provided Makefile.
Generating a Static Library (libft.a)
To compile the static version of the library, run:
make
- Or
make static
Generating a Shared Library (libft.so)
To compile the static version of the library, run:
make shared
Using the Library
To compile your program with libft, use one of the following methods:
- Direct Linking
cc -Wall -Wextra -Werror -Iinclude test.c libft.a -o foo
- Or
- Using the Library Flag
cc -Wall -Wextra -Werror -Iinclude test.c -L. -lft -o foo
NOTE
- Replace
test.cwith your actual source file.
Cleanup
- To remove Object files, run:
make clean
- To remove
libft.a,libft.soand object files, run:
make fclean
