This project has been created as part of the 42 curriculum by nkerstin.
libft is a custom C library built from scratch as part of the 42 school curriculum. The goal of this project is to re-implement a set of standard C library functions — and extend them with additional utility functions — to build a personal toolkit that can be reused throughout future 42 projects.
The library is organized into the following categories:
Re-implementations of standard C library functions, behaving identically to their originals:
| Function | Description |
|---|---|
ft_isalpha |
Checks if a character is alphabetic |
ft_isdigit |
Checks if a character is a digit |
ft_isalnum |
Checks if a character is alphanumeric |
ft_isascii |
Checks if a character is a valid ASCII character |
ft_isprint |
Checks if a character is printable in ACII |
ft_strlen |
Returns the length of a string |
ft_memset |
Fills memory with a constant byte |
ft_bzero |
Zeroes out a block of memory |
ft_memcpy |
Copies memory area |
ft_memmove |
Copies memory area, handling overlap |
ft_strlcpy |
Size-bounded string copy |
ft_strlcat |
Size-bounded string concatenation |
ft_toupper |
Converts a character to uppercase |
ft_tolower |
Converts a character to lowercase |
ft_strchr |
Locates first occurrence of a character in a string |
ft_strrchr |
Locates last occurrence of a character in a string |
ft_strncmp |
Compares two strings up to n characters |
ft_memchr |
Scans memory for a character |
ft_memcmp |
Compares two memory areas |
ft_strnstr |
Locates a substring in a string (length-limited) |
ft_atoi |
Converts a string to an integer |
ft_calloc |
Allocates and zeroes memory |
ft_strdup |
Duplicates a string using malloc |
Utility functions not in the standard library but commonly useful:
| Function | Description |
|---|---|
ft_substr |
Extracts a substring from a string |
ft_strjoin |
Concatenates two strings into a new one |
ft_strtrim |
Trims characters from both ends of a string |
ft_split |
Splits a string by a delimiter into an array |
ft_itoa |
Converts an integer to a string |
ft_strmapi |
Applies a function to each character of a string (new string) |
ft_striteri |
Applies a function to each character of a string (in-place) |
ft_putchar_fd |
Outputs a character to a file descriptor |
ft_putstr_fd |
Outputs a string to a file descriptor |
ft_putendl_fd |
Outputs a string followed by newline to a file descriptor |
ft_putnbr_fd |
Outputs an integer to a file descriptor |
Functions for manipulating a singly linked list (t_list):
The requierd t_list typedef struct:
typedef struct s_list
{
void *content;
struct s_list *next;
} t_list;| Function | Description |
|---|---|
ft_lstnew |
Creates a new list node |
ft_lstadd_front |
Adds a node at the front of the list |
ft_lstsize |
Returns the number of nodes in the list |
ft_lstlast |
Returns the last node of the list |
ft_lstadd_back |
Adds a node at the back of the list |
ft_lstdelone |
Deletes a single node |
ft_lstclear |
Deletes and frees the entire list |
ft_lstiter |
Applies a function to each node's content |
ft_lstmap |
Creates a new list by applying a function to each node |
- A C compiler:
cc make
Compile the library with:
makeThis produces libft.a, the static library archive that can then be used in different projects.
| Rule | Action |
|---|---|
make / make all |
Compiles the library |
make clean |
Removes object files |
make fclean |
Removes object files and libft.a |
make re |
Runs fclean then all |
- man pages — Linux manual pages
- Linked Lists — GeeksforGeeks
- Implement Your Own itoa — GeeksforGeeks
- Stack Overflow
- More GeeksforGeeks
AI tools (mostly Claude) were used during this project for the following purposes:
- Understanding behavior of funcs. and edge cases: Querying expected behavior of functions like
ft_memmovewhen source and destination overlap, orft_strlcatandft_strlcpyreturn values. - Debugging: Describing unexpected segfaults or memory leaks and getting guidance on likely causes.
- README drafting: Structuring and formatting this documentation file.
AI was not used to write or generate any C source code submitted for evaluation.