This project aims to code a C library regrouping usual functions that will be used for all next projects. Later projects are included to the library. Ex: ft_printf.
Some functions present the same prototype and behaviors as the originals. Others are either not included in the libc, or included in a different form.
Re-code of a set of the libc functions, as defined in their man.
Function | Description |
---|---|
ft_isalpha |
alphabetic character check |
ft_isdigit |
digit character check |
ft_isalnum |
alphanumeric character check |
ft_isascii |
ASCII character check |
ft_isprint |
printable character check |
ft_strlen |
calculate the length of a string |
ft_memset |
fill memory with a constant byte |
ft_bzero |
zero a byte string |
ft_memcpy |
copies n bytes from src to dst |
ft_memmove |
copies n bytes from src to dst |
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 |
ft_strrchr |
locate character in string backwards |
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 a string to an integer |
Function | Description |
---|---|
ft_calloc |
allocate dynamic memory |
ft_strdup |
duplicate a string |
ft_substr |
return a substring from a string |
ft_strjoin |
string concatenation |
ft_strtrim |
copy string trimming selected characters |
ft_split |
split string with character as delimiter |
ft_itoa |
return a string representing an integer |
ft_strmapi |
apllies the provided function to each character |
ft_striteri |
applies the provided function to each character passed by reference |
ft_putchar_fd |
outputs character to fd |
ft_putstr_fd |
outputs string to fd |
ft_putendl_fd |
outputs string to fd followed by a new line |
ft_putnbr_fd |
outputs integer to fd |
The bonus functions are made to manage a list defined by the following struct:
typedef struct s_list
{
void *content; /* the data contained in the element */
struct s_list *next; /* the next element’s address || NULL if last element */
} t_list;
Function | Description |
---|---|
ft_lstnew |
create a new element |
ft_lstadd_front |
adds the element at the beginning of the list |
ft_lstadd_back |
adds the element at the end of the list |
ft_lstsize |
counts the number of elements in a list |
ft_lstlast |
returns the last element of the list |
ft_lstdelone |
deletes the content and free the element |
ft_lstclear |
deletes and free every element and its successors |
ft_lstiter |
iterates the list applying the provided function |
ft_lstmap |
iterates the list applying the provided function and return a list of affected elements |
The following functions have been added to the library as result of later projects.
Function | Description |
---|---|
get_next_line |
Returns a line, read from a file descriptor |
ft_printf |
Re-code of printf |
To compile the library, either run:
$ make
or if the ft_printf is allowed in the project:
$ make printf
Then, include its header in the code:
#include "libft.h"
or, with ft_printf allowed, you can add:
#include "ft_printf.h"
Lastly, add the following flags when compiling the project:
-L./libft_dir -I./libft_dir/includes -lft
This work is published under the terms of 42 Unlicense