“Libft – your own first library” is an individual project at 42, it is the second one i have worked on after the “Piscine Reloaded one”.
The aim of this project is to code a C library regrouping usual functions that we’ll be allowed to use in all our other projects. At 42 we are not allowed to use standard C library function, we can use only function we coded ourself. So the longer term goal of this library is to grow with our own function.
For this library there are only 3 standard library function allowed are write() from <unistd.h>, malloc() and free() from <stdlib.h>. We are allowed also to use <string.h> for accessing size_t and NULL.
Here is the link to the GitHub repository: https://github.com/nmanzini/libft-42
LIBFT is the second project we worked on after starting the school. This project required a lot of checking for all the possible cases in which a standard function can fail or not. This library has been thoroughly checked.
Lib C Functions | 42 Functions | List Functions |
---|---|---|
memset | ft_memalloc | ft_lstnew |
bzero | ft_memdel | ft_lstdelone |
memcpy | ft_strnew | ft_lstdel |
memccpy | ft_strdel | ft_lstadd |
memmove | ft_strclr | ft_lstiter |
memchr | ft_striter | ft_lstmap |
memcmp | ft_striteri | |
strlen | ft_strmap | |
strdup | ft_strmapi | |
strcpy | ft_strequ | |
strncpy | ft_strnequ | |
strcat | ft_strsub | |
strlcat | ft_strjoin | |
strchr | ft_strtrim | |
strrchr | ft_strsplit | |
strstr | ft_itoa | |
strnstr | ft_putchar | |
strcmp | ft_putstr | |
strncmp | ft_putendl | |
atoi | ft_putnbr | |
isalpha | ft_putchar_fd | |
isdigit | ft_putstr_fd | |
isalnum | ft_putendl_fd | |
isascii | ft_putnbr_fd | |
isprint | ||
toupper | ||
tolower |
There are 3 kinds of function:
- Lib C Functions: are the function coming from standard C libraries have a “ft_” before them to avoid conflict with the original ones.
- 42 Functions: Functions used at Ecole 42, mainly memory and string manipulation
- List Functions: Used for list creation and manipulation.
Recreating all these function is a great exercise to understand what these function do in detail, their limitation and unexpected results. Unit testing them is a even greater challenge than writing them.
At 42 we don’t have to study what a function does, when you are stuck for hours recoding them you are forced to understand them deeply.