This project has been created as part of the 42 curriculum by dchernyk.
Libft is a library for the C programming language. The goal is to practice Makefile, header files, and function linking in order to create a static library. It also helps in learning how linked lists work.
To use the Makefile commands, you need to be in the project directory and run:
| Command | Description |
|---|---|
make |
compiles every .c file into .o files and links them into libft.a |
all |
default behavior |
clean |
removes all .o files |
fclean |
removes all .o and .a files |
re |
removes all .o and .a files and runs make again |
https://github.com/xicodomingues/francinette
It has been abandoned for a long time, but the tests still cover most topics. It is made for the old libft subject, when the bonus part was not mandatory. In order to run it, all linked files need to be added to the BONUS variable in the Makefile. Then create .o files from them.
BOFILES = $(BCFILES:.c=.o)Create a bonus rule to build the archive.
bonus: $(NAME) $(BOFILES)
ar rcs $(NAME) $(BOFILES)If https://github.com/Tripouille/libftTester is installed:
so:
$(CC) -fPIC $(CFLAGS) -shared -o libft.so $(CFILES)AI was used as an assistant tool (Claude, ChatGPT, and Gemini). Created AI agents do not provide direct answers and behave according to the 42 AI approach. The main behavior is to encourage me to explain my code and provide information so that, in the end, I have a full understanding of the situation.
| Function | Description |
|---|---|
isalpha |
Checks if a character is an alphabetic letter (A–Z or a–z). |
isdigit |
Checks if a character is a decimal digit (0–9). |
isalnum |
Checks if a character is alphanumeric (A–Z, a–z, or 0–9). |
isascii |
Checks if a character is within the ASCII range (0–127). |
isprint |
Checks if a character is printable, including space. |
strlen |
Returns the length of a string excluding the null terminator. |
memset |
Fills a block of memory with a specified byte value. |
bzero |
Sets a block of memory to zero. |
memcpy |
Copies memory from source to destination (no overlap handling). |
memmove |
Copies memory safely, handling overlapping regions. |
strlcpy |
Copies a string into a buffer with size limitation and guarantees null-termination. |
strlcat |
Appends a string to another with size limitation and null-termination. |
toupper |
Converts a lowercase letter to uppercase if possible. |
tolower |
Converts an uppercase letter to lowercase if possible. |
strchr |
Finds the first occurrence of a character in a string. |
strrchr |
Finds the last occurrence of a character in a string. |
strncmp |
Compares two strings up to a given number of characters. |
memchr |
Searches for a byte in a memory block. |
memcmp |
Compares two memory blocks byte by byte. |
strnstr |
Searches for a substring in a string within a limited length. |
atoi |
Converts a string to an integer. |
calloc |
Allocates memory for an array and initializes it to zero. |
strdup |
Allocates memory and returns a duplicate of a string. |
ft_substr |
Allocates and returns a substring from string s, starting at index start and with a maximum length of len. Returns NULL if allocation fails. |
ft_strjoin |
Allocates and returns a new string which is the result of concatenating s1 and s2. Returns NULL if allocation fails. |
ft_strtrim |
Allocates and returns a copy of s1 with all characters in set removed from the beginning and the end of the string. Returns NULL if allocation fails. |
ft_split |
Allocates and returns an array of strings obtained by splitting s using the character c as a delimiter. The array is NULL-terminated. Returns NULL if allocation fails. |
ft_itoa |
Allocates and returns a string representing the integer n, handling negative numbers. Returns NULL if allocation fails. |
ft_strmapi |
Applies function f to each character of string s, using its index and character, and returns a new allocated string with the results. Returns NULL if allocation fails. |
ft_striteri |
Applies function f to each character of string s, passing its index and a pointer to the character, allowing in-place modification. No return value. |
ft_putchar_fd |
Outputs character c to file descriptor fd using write. |
ft_putstr_fd |
Outputs string s to file descriptor fd using write. |
ft_putendl_fd |
Outputs string s followed by a newline to file descriptor fd using write. |
ft_putnbr_fd |
Outputs integer n to file descriptor fd using write, handling negative numbers. |
ft_lstnew |
Allocates and returns a new list node. The content field is initialized with the given parameter and next is set to NULL. |
ft_lstadd_front |
Adds the node new at the beginning of the list pointed to by lst. |
ft_lstsize |
Returns the number of nodes in the linked list. |
ft_lstlast |
Returns the last node of the linked list. |
ft_lstadd_back |
Adds the node new at the end of the list pointed to by lst. |
ft_lstdelone |
Frees the memory of a single node using del to free its content, then frees the node itself (does not affect other nodes). |
ft_lstclear |
Deletes and frees the entire list, applying del to each node's content, and sets the list pointer to NULL. |
ft_lstiter |
Iterates through the list and applies function f to the content of each node. |
ft_lstmap |
Creates a new list by applying function f to each node's content. Uses del to free content if allocation fails, and returns the new list or NULL on failure. |