Libft is the first project at 42 School that requires students to re-code several functions from the standard C library. The goal is to create a personal library with basic utility functions that will be used in future projects.
This library contains recoded standard C functions, additional useful functions for string manipulation, memory management, linked list operations, and more.
Recreated functions from the standard C library:
| 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 length of string |
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 copy |
ft_strlcat |
Size-bounded string concatenation |
ft_toupper |
Convert lowercase letter to uppercase |
ft_tolower |
Convert uppercase letter to lowercase |
ft_strchr |
Locate character in string |
ft_strrchr |
Locate character in string from the end |
ft_strncmp |
Compare two strings |
ft_memchr |
Scan memory for a character |
ft_memcmp |
Compare memory areas |
ft_strnstr |
Locate a substring in a string |
ft_atoi |
Convert string to integer |
ft_calloc |
Allocate and zero-initialize array |
ft_strdup |
Create a duplicate of a string |
Additional useful functions:
| Function | Description |
|---|---|
ft_substr |
Extract substring from string |
ft_strjoin |
Concatenate two strings |
ft_strtrim |
Trim beginning and end of string |
ft_split |
Split string using a delimiter |
ft_itoa |
Convert integer to string |
ft_strmapi |
Apply function to each character with index |
ft_striteri |
Apply function to each character 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 with newline to a file descriptor |
ft_putnbr_fd |
Output a number to a file descriptor |
Functions for linked list manipulation:
| Function | Description |
|---|---|
ft_lstnew |
Create new list element |
ft_lstadd_front |
Add element at beginning of list |
ft_lstsize |
Count elements in a list |
ft_lstlast |
Get last element of list |
ft_lstadd_back |
Add element at end of list |
ft_lstdelone |
Delete element from list |
ft_lstclear |
Delete and free list |
ft_lstiter |
Apply function to each element of list |
ft_lstmap |
Apply function and create new list |
- GCC compiler
- Make
Clone this repository:
git clone https://github.com/Tanathorn-Rin/42-Libft.git
cd 42-LibftCompile the library:
makeFor bonus functions:
make bonusInclude the header in your C files:
#include "libft.h"Compile your program with the library:
gcc -Wall -Wextra -Werror your_program.c -L. -lft -o your_programTo test the functions, you can use the following testers (not included in this repository):
42 is a global education initiative that offers a new way of learning technology: no teachers, no classrooms, students learning from their fellow students (peer to peer learning), with a methodology that develops both computing and life skills. The 42 cursus is free for whoever is approved in its selection process.
- Tanathorn-Rin - GitHub Profile