About • How to use • Mandatory • Bonus • Norminette • Contributing • License
The first project at 42, libft, involves learning how the standard functions of C programming work by writing them from scratch and creating a personal library. This project is vital as the library will be used in future assignments at 42.
If you're a 42 student, it's highly recommended that you go through the process of writing your code and testing it yourself rather than copying and pasting code that you only partially understand. If you've completed your piscine, there's no reason why you couldn't tackle this project on your own! Be patient and thorough.
- Subject
PDF
- References
GitHub
git clone git@github.com:jotavare/libft.git
cd libft/libft
make
#include "libft.h"
make
- Compile libft mandatory files.
make bonus
- Compile libft bonus files.
make all
- Compile mandatory + bonus files.
make clean
- Delete all .o (object files) files.
make fclean
- Delete all .o (object file) and .a (executable) files.
make re
- Use rules fclean
+ all
.
The mandatory functions in libft include both functions from the standard C library and other functions that are useful for character, string, and memory manipulation. These 34 mandatory functions are essential to achieving a grade of 100.
Function | Description |
---|---|
ft_isalpha |
Alphabetic character test. |
ft_isdigit |
Decimal-digit character test. |
ft_isalnum |
Alphanumeric character test. |
ft_isascii |
Test for ASCII character. |
ft_toupper |
Lower case to upper case letter conversion. |
ft_tolower |
Upper case to lower case letter conversion. |
Function | Description |
---|---|
ft_strlen |
Find the length of the string. |
ft_strlcpy |
Size-bounded string copying. |
ft_strlcat |
Size-bounded string concatenation. |
ft_strchr |
Locate the character in the string (first occurrence). |
ft_strrchr |
Locate the character in the string (last occurrence). |
ft_strncmp |
Compare strings (size-bounded). |
ft_strnstr |
Locate a substring in a string (size-bounded) |
ft_substr |
Extract substring from a string. |
ft_strjoin |
Concatenate two strings into a new string (with malloc). |
ft_strtrim |
Trim the beginning and end of the string with the specified characters. |
ft_split |
Split string, with specified character as delimiter, into an array of strings. |
ft_strmapi |
Create a new string by modifying the string with a specified function. |
ft_striteri |
Iterates through a string, enabling character and index manipulation. |
Function | Description |
---|---|
ft_calloc |
Memory allocation. |
ft_memset |
Write a byte to a byte string. |
ft_bzero |
Write zeroes to a byte string. |
ft_memcpy |
Copy memory area. |
ft_memmove |
Copy byte string. |
ft_memchr |
Locate byte in byte string. |
ft_memcmp |
Compare byte string. |
ft_strdup |
Save a copy of a string (with malloc). |
Function | Description |
---|---|
ft_atoi |
Convert the ASCII string to an integer. |
ft_itoa |
Convert integer to ASCII string. |
Function | Description |
---|---|
ft_putchar_fd |
Output a character to the given file. |
ft_putstr_fd |
Output string to the given file. |
ft_putendl_fd |
Output string to given file with newline. |
ft_putnbr_fd |
Output integer to the given file. |
The bonus functions in libft are focused on list manipulation and are worth an additional 25 towards the final grade. To achieve a grade of 125, all 9 bonus functions and 34 mandatory functions must be completed accurately.
Function | Description |
---|---|
ft_lstnew |
Create new list. |
ft_lstadd_front |
Add a new element at the beginning of the list. |
ft_lstadd_back |
Add a new element at the end of the list. |
ft_lstsize |
Count elements of a list. |
ft_lstlast |
Find the last element of the list. |
ft_lstdelone |
Delete element from the list. |
ft_lstclear |
Delete the sequence of elements of the list from a starting point. |
ft_lstiter |
Apply function to the content of all list elements. |
ft_lstmap |
Apply function to the content of all list elements into a new list. |
At 42 School, it is expected that almost every project is written following the Norm, which is the coding standard of the school.
- No for, do...while, switch, case, goto, ternary operators, or variable-length arrays allowed;
- Each function must be a maximum of 25 lines, not counting the function's curly brackets;
- Each line must be at most 80 columns wide, with comments included;
- A function can take 4 named parameters maximum;
- No assigns and declarations in the same line (unless static);
- You can't declare more than 5 variables per function;
- ...
- 42 Norms - Information about 42 code norms.
PDF
- Norminette - Tool to respect the code norm, made by 42.
GitHub
- 42 Header - 42 header for Vim.
GitHub
If you find any issues or have suggestions for improvements, feel free to fork the repository and open an issue or submit a pull request.
This project is available under the MIT License. For further details, please refer to the LICENSE file.