This project has been created as part of the 42 curriculum by kjurkows
libft is a substitute library for libc & libbsd.
All functions are prefixed by ft_.
It implements most used libc/libbsd functions in a safe way, while also implementing additional functions used in 42 curriculum, those include advanced string operations as well as linked lists.
See Detailed description for list of implemented functions.
To compile libft just use make
all: compile and link everything (default)
libft.a: linklibft
clean: clean objects (remove*.ofiles)
fclean: full clean (remove everything compiled)
re: recompile and relink everything
The library is tested with a custom test suite, which can be found here.
man- doxygen manual
- C language section on cppreference
- GCC git repository
AI mode was used for searching through documentations and references.
AI summaries were used to summarize extensive documentations/references (for ease of reading).
AI inline suggestions were used for repetitive tasks, such as:
- Writing doxygen docs in
libft.h - Creating
Makefile
Main IDE used was VS Code with a few extensions:
42 ft count line,42 Headerand42 Norminette Highlighterwere used as aid for La Norme complianceC/C++,C/C++ DevToolsandMakefile Toolswere used for IntelliSense
norminette was used to check La Norme compliance
make, gcc & ar are used for compilation
libft consists of 3 parts:
libcfunctions- Additional functions
- linked list
Each function is implemented in a separate file and compliant with The Norme
See below for a list of implemented functions and their brief descriptions.
For detailed descriptions look inside libf.h or specific files.
Functions from libc that are most commonly needed during 42 curriculum
ft_isalpha- check for an alphabetic characterft_isdigit- check for a digitft_isalnum- check for an alphanumeric characterft_isascii- check is the character in ASCII rangeft_isprint- check is the character printable (non-control)
ft_tolower- convert character to uppercaseft_toupper- convert character to lowercase
ft_strlen- calculate string lengthft_strlcpy1 - safely copy a stringft_strlcat1 - safely concatenate two stringsft_strchr- locate character in a stringft_strrchr- locate character in a string (reverse)ft_strncmp- compare two stringsft_strnstr1 - locate a substring in a stringft_strdup- duplicate a string
ft_memset- fill memory area with constant byteft_bzero- fill memory area with zeroft_memcpy- copy memory areaft_memmove- move memory areaft_memchr- scan memory for a byteft_memcmp- compare memory areasft_calloc- allocate dynamic memory for an array
ft_atoi- convert string to a number
ft_substr- create a substring from a stringft_strjoin- join two strings into a new oneft_strtrim- trim a stringft_split- split a stringft_itoa- convert number to stringft_strmapi- map a stringft_striteri- iterate over a string
ft_putchar_fd- write a characterft_putstr_fd- write a stringft_putendl_fd- write a string ending with new lineft_putnbr_fd- write a number
Linked list node is implemented as such:
/// linked list node
typedef struct s_list
{
void *content; ///< data contained in the node
struct s_list *next; ///< pointer to the next node or `0` (last node)
} t_list;ft_lstnew- create a new list nodeft_lstadd_front- add node to front of listft_lstsize- count nodes in a listft_lstlast- get last node of a listft_lstadd_back- add node to the back of a listft_lstdelone- delete a nodeft_lstclear- delete a listft_lstiter- iterate over a listft_lstmap- map a list