This project was completed with a grade of 125/100 ✅ on October 26, 2022.
This project, Libft, is an essential part of the 42 curriculum, where the goal is to learn how fundamental C functions work by re-implementing them from scratch. By creating this custom library, you'll gain a deeper understanding of C programming and enhance your coding skills. Libft includes standard libc functions as well as other utility functions that will be used in future 42 projects. Through this process, you'll develop the knowledge and expertise to write clean, efficient code that you can rely on in your upcoming assignments. The project is designed to be a hands-on learning experience, encouraging trial and error, debugging, and thorough testing to ensure the correctness and efficiency of your functions.
In this project, you are allowed to use only three C standard library functions: write(), malloc(), and free(). However, you cannot use them freely; they are only permitted under specific conditions. You need to compress them into a single archive for easy reuse in future projects.
This project is divided into three essential parts:
These functions already exist in C, so the requirement here is to recreate them to behave in the same way or as close as possible to the original functions from the C standard library.
No | Function Name | Link | No | Function Name | Link |
---|---|---|---|---|---|
1 | ft_memset |
ft_memset | 13 | ft_strnstr |
ft_strnstr |
2 | ft_bzero |
ft_bzero | 14 | ft_strncmp |
ft_strncmp |
3 | ft_memcpy |
ft_memcpy | 15 | ft_atoi |
ft_atoi |
4 | ft_memccpy |
ft_memccpy | 16 | ft_isalpha |
ft_isalpha |
5 | ft_memmove |
ft_memmove | 17 | ft_isdigit |
ft_isdigit |
6 | ft_memchr |
ft_memchr | 18 | ft_isalnum |
ft_isalnum |
7 | ft_memcmp |
ft_memcmp | 19 | ft_isascii |
ft_isascii |
8 | ft_strlen |
ft_strlen | 20 | ft_isprint |
ft_isprint |
9 | ft_strlcpy |
ft_strlcpy | 21 | ft_toupper |
ft_toupper |
10 | ft_strlcat |
ft_strlcat | 22 | ft_tolower |
ft_tolower |
11 | ft_strchr |
ft_strchr | 23 | ft_calloc |
ft_calloc |
12 | ft_strrchr |
ft_strrchr | 24 | ft_strdup |
ft_strdup |
These functions do not exist in C (they may exist in other languages), so you need to create them to help you in future C projects. The challenge here is that the functions must not cause segmentation faults or memory leaks under any circumstances.
No | Function Name | Link | No | Function Name | Link |
---|---|---|---|---|---|
1 | ft_substr |
ft_substr | 6 | ft_strmapi |
ft_strmapi |
2 | ft_strjoin |
ft_strjoin | 7 | ft_putchar_fd |
ft_putchar_fd |
3 | ft_strtrim |
ft_strtrim | 8 | ft_putstr_fd |
ft_putstr_fd |
4 | ft_split |
ft_split | 9 | ft_putendl_fd |
ft_putendl_fd |
5 | ft_itoa |
ft_itoa | 10 | ft_putnbr_fd |
ft_putnbr_fd |
This part is not required to validate the project, but it is very important for exploring data structures, specifically singly linked lists. A linked list is a linear data structure where each element, called a node, is connected to the next one using pointers. Through this, you will learn how to create a linked list, delete a node, add a node at the front or back, and delete the entire linked list.
No | Function Name | Link | No | Function Name | Link |
---|---|---|---|---|---|
1 | ft_lstnew |
ft_lstnew | 6 | ft_lstdelone |
ft_lstdelone |
2 | ft_lstadd_front |
ft_lstadd_front | 7 | ft_lstclear |
ft_lstclear |
3 | ft_lstsize |
ft_lstsize | 8 | ft_lstiter |
ft_lstiter |
4 | ft_lstlast |
ft_lstlast | 9 | ft_lstmap |
ft_lstmap |
5 | ft_lstadd_back |
ft_lstadd_back |