Libft is the first project at 42 School, focusing on recreating various standard C library functions, as well as additional utility functions that will be used throughout the entire curriculum.
"By rewriting these functions, you'll gain a deeper understanding of their inner workings and become more proficient in C programming."
The purpose is to build your own library, which you'll expand and use in your future C projects at 42.
- Reimplement standard C library functions with identical behaviors
- Create additional utility functions not found in the standard library
- Learn to create and manage a library in C
- Deepen understanding of memory management, strings, and data structures in C
- Apply rigorous error handling and edge case management
Reimplementation of standard C library functions
Function | Description |
---|---|
ft_isalpha | Check if character is alphabetic |
ft_isdigit | Check if character is a digit |
ft_isalnum | Check if character is alphanumeric |
ft_isascii | Check if character is in ASCII table |
ft_isprint | Check if character is printable |
ft_strlen | Calculate string length |
ft_memset | Fill memory with a constant byte |
ft_bzero | Zero a byte string |
ft_memcpy | Copy memory area |
ft_memmove | Copy memory area with overlap handling |
ft_strlcpy | Size-bounded string copying |
ft_strlcat | Size-bounded string concatenation |
ft_toupper | Convert character to uppercase |
ft_tolower | Convert character to lowercase |
ft_strchr | Locate character in string (first occurrence) |
ft_strrchr | Locate character in string (last occurrence) |
ft_strncmp | Compare two strings (size-bounded) |
ft_memchr | Scan memory for a character |
ft_memcmp | Compare memory areas |
ft_strnstr | Locate a substring in a string (size-bounded) |
ft_atoi | Convert ASCII string to integer |
ft_calloc | Allocate and zero-initialize array |
ft_strdup | Create a duplicate of the string |
Functions that are either not in the libc, or that are part of it but in a different form
Function | Description |
---|---|
ft_substr | Extract substring from string |
ft_strjoin | Concatenate two strings |
ft_strtrim | Trim beginning and end of string with specific set of chars |
ft_split | Split string using a character as delimiter |
ft_itoa | Convert integer to ASCII string |
ft_strmapi | Apply function to each character of a string with index |
ft_striteri | Apply function to each character of a string with index |
ft_putchar_fd | Output a character to a file descriptor |
ft_putstr_fd | Output a string to a file descriptor |
ft_putendl_fd | Output a string to a file descriptor, followed by a newline |
ft_putnbr_fd | Output a number to a file descriptor |
Functions to manipulate linked lists
Function | Description |
---|---|
ft_lstnew | Create a new list element |
ft_lstadd_front | Add new element at beginning of list |
ft_lstsize | Count elements in a list |
ft_lstlast | Return the last element of the list |
ft_lstadd_back | Add new element at end of list |
ft_lstdelone | Delete element from list using a delete function on content |
ft_lstclear | Delete sequence of elements from list |
ft_lstiter | Apply function to content of all list's elements |
ft_lstmap | Apply function to content of all list's elements and create new list |
The library was extensively tested using:
- 42 School's Moulinette
- Unit tests with libft-unit-test
- War Machine
- Custom test cases for edge conditions
- Deep understanding of C memory management
- String manipulation techniques
- Implementation of data structures (linked lists)
- Rigorous function testing and edge case handling
- Makefile creation and usage
- Library creation and management
Metric | Value |
---|---|
Final Score | 125/100 |
Functions Implemented | 43 |
Lines of Code | ~1500 |
Completion Time | 2 weeks |