The libft
project is the first one of my journey as a 42 student and is going to play a crucial role in upcoming assignments, since the library created here is going to be used in future C projects. Here, I created my very first C library from scratch.
This project pushed me to dig deep into how the original replicated functions work, helping me develop a comprehensive understanding of their inner workings and how to enhance them. It's not just about meeting project requirements; it's about aiming for excellence and crafting a library that I will use in future projects.
- Reminder: ❗️ You can check all my 42 projects at 42 Cursus
Makefile |
The Makefile for building the libft library. |
libft.h |
The header file containing function prototypes and necessary definitions. |
Character Classification | |||
ft_isalnum.c |
Check if a character is alphanumeric. | ft_isalpha.c |
Check if a character is alphabetic. |
ft_isascii.c |
Check if a character is an ASCII character. | ft_isdigit.c |
Check if a character is a digit. |
ft_isprint.c |
Check if a character is a printable character. | ||
Case conversion | |||
ft_tolower.c |
Convert a character to lowercase. | ft_toupper.c |
Convert a character to uppercase. |
String Manipulation | |||
ft_strlen.c |
Calculate the length of a string. | ft_strlcpy.c |
Safely copy a string. |
ft_strlcat.c |
Safely concatenate strings | ft_atoi.c |
Convert a string to an integer. |
String Search | |||
ft_strnstr.c |
Locate a substring in a string. | ft_strchr.c |
Locate the first occurrence of a character in a string. |
ft_strncmp.c |
Compare two strings up to a specified number of characters. | ft_strrchr.c |
Locate the last occurrence of a character in a string. |
Memory Manipulation | |||
ft_memset.c |
Fill memory with a constant byte. | ft_bzero.c |
Set the first `n` bytes of memory to zero. |
ft_memcpy.c |
Copy memory area. | ft_memmove.c |
Copy memory area taking overlapping into account. |
ft_memchr.c |
Locate the first occurrence of a byte in memory. | ft_memcmp.c |
Compare memory areas. |
ft_calloc.c |
Allocate and clear memory for an array. | ft_strdup.c |
Duplicate a string. |
ft_substr.c |
Extract a substring from a string. | ft_strdup.c |
Concatenate two strings. |
ft_strtrim.c |
Trim leading and trailing a set of characters from a string. | ft_split.c |
Split a string into an array of substrings. |
ft_strjoin.c |
Using malloc returns a new string as a result of the concatenation of 2 strings. | ft_itoa.c |
Convert an integer to a string. |
ft_striteri.c |
Apply a function to each character of a string with an index. | ft_strmapi.c |
Returns a string applying a function to each character of a string. |
Output Functions | |||
ft_putchar_fd.c |
Output a character to a file descriptor. | ft_putstr_fd.c |
Output a string to a file descriptor. |
ft_putendl_fd.c |
Output a string followed by a newline to a file descriptor. | ft_putnbr_fd.c |
Output an integer to a file descriptor. |
ft_lstnew_bonus.c |
Create a new list element. | ft_lstadd_front_bonus.c |
Add a new element to the beginning of a list. |
ft_lstsize_bonus.c |
Get the number of elements in a list. | ft_lstlast_bonus.c |
Get the last element of a list. |
ft_lstadd_back_bonus.c |
Add a new element to the end of a list. | ft_lstdelone_bonus.c |
Delete a node from a list without deleting its content. |
ft_lstclear_bonus.c |
Delete and free the memory of a list node and its consecutives. | ft_lstiter_bonus.c |
Apply a function to each element of a list. |
ft_lstmap_bonus.c |
Creates a list by iterating and applying a function of a existing list. |
- Linux
- macOS
Before using Libft, you need:
- GCC: The GNU Compiler Collection.
Make use of the make
command to build and compile the library
Rules Available in the Makefile
Rule | Description |
---|---|
all | Compiles the library without the bonus files |
bonus | Compiles the library with bonus files |
clean | Removes every created object |
fclean | Runs make clean and removes the libft.a |
re | Runs make fclean and then make all |
rebonus | Runs make fclean and then make bonus |
- Compile without bonus:
cd libft
make all
- Delete objects and libft.a and compile with bonus:
make rebonus