This project aims to code a C library regrouping usual functions that can be used in all other 42 projects.
The content of this repository is subject to constant change as new general functions developed during other projects are added here.
Command | Usage |
---|---|
make |
creates .o files for each function as well as the main library file, libft.a |
make clean |
removes the .o files used to create the library |
make fclean |
removes the .o & .a files used to create the library |
make re |
removes all .o & .a files then remakes them |
📁 GNL
Function | Description |
---|---|
get_next_line.c | returns a line read from a file descriptor |
📁 ft_printf
Function | Description |
---|---|
ft_printf.c | prints to STDOUT and returns an int value equal to the number of printed chars (%cspduxX) |
📁 io
Function | Description |
---|---|
ft_putchar_fd.c | outputs a character to the given file descriptor |
ft_putendl_fd.c | outputs a string to the given file descriptor followed by a \n |
ft_putnbr_fd.c | outputs an integer to the given file descriptor |
ft_putstr_fd.c | outputs a string to the given file descriptor |
📁 lists
Function | Description |
---|---|
ft_lstadd_back.c | adds a new element at the end of the list |
ft_lstadd_front.c | adds a new element at the beginning of the list |
ft_lstclear.c | deletes and frees the given element and every successor of that element |
ft_lstdelone.c | deletes and frees the given element |
ft_lstiter.c | iterates through a list while applying the function passed to the content of each element |
ft_lstlast.c | returns the last element of the list |
ft_lstmap.c | iterates through a list while applying the function passed to the content of each element and creating a new list with the results |
ft_lstnew.c | allocates (with malloc(3)) and returns a new element |
ft_lstsize.c | counts the number of elements in a list |
📁 memalloc
Function | Description |
---|---|
free_table.c | frees all elements of a 2d array |
ft_calloc.c | contiguously allocates memory that is filled with bytes of value zero |
ft_realloc.c | reallocates the given area of memory |
ft_xcalloc.c | same as calloc(), but it directly exits in case of memory allocation error |
xfree.c | frees a pointer after checking it isn't NULL |
📁 strings
Function | Description |
---|---|
ft_atoi.c | converts ASCII string to integer |
ft_atol.c | converts ASCII string to long integer |
ft_bzero.c | erases the data in the n bytes of the memory by writing '\0' to that area |
ft_itoa.c | allocates and returns a string representing the integer passed as argument |
ft_memchr.c | scans n bytes of the pointed memory for the first instance of a char |
ft_memcmp.c | compares the first n bytes of the block of memory from 2 strings |
ft_memcpy.c | copies n bytes from one memory area to another |
ft_memmove.c | copies n bytes from string to to another using a temporary array to handle overlap |
ft_memset.c | fill a block of memory with a particular value |
ft_split.c | splits a string, with specified character as delimiter, into an array of strings |
ft_strchr.c | locates the first occurrence of c (converted to a char) in the string |
ft_strcmp.c | compares (lexicographically) two strings |
ft_strdup.c | allocates sufficient memory for a copy a string copies and returns a pointer to it |
ft_striteri.c | applies the function f to each character of the string passed as argument |
ft_strjoin.c | allocates and returns a new string (concatenation of two strings) |
ft_strjoin_free.c | same as ft_strjoin(), but it frees the old string |
ft_strlcat.c | appends two strings |
ft_strlcpy.c | size-bounded string copying |
ft_strlen.c | counts the numbers of characters preceding the terminating NUL-character of a string |
ft_strmapi.c | applies a function to each character of a string, creating a new string with the modifications |
ft_strncmp.c | compares (lexicographically) up to n characters of two strings |
ft_strnstr.c | locates the first occurrence of the null-terminated substring in the a string, where not more than n characters are searched |
ft_strrchr.c | locate last occurrence of character in string |
ft_strtrim.c | allocates and returns a copy of a string with the characters specified in ’set’ removed from the beginning and the end of the string |
ft_substr.c | allocates and returns a substring from another string |
📁 types
Function | Description |
---|---|
ft_isalnum.c | tests for any character for which ft_isalpha or ft_isdigit is true |
ft_isalpha.c | tests for any character for which ft_isupper or ft_islower is true |
ft_isascii.c | tests for any ASCII character between 0 and octal 0177 inclusive |
ft_isdigit.c | tests for a decimal digit character |
ft_isprint.c | tests for any printing character, including space |
ft_isset.c | tests if the character is part of a set |
ft_isspace.c | tests if a character is a white-space character |
ft_tolower.c | upper case to lower case letter conversion |
ft_toupper.c | lower case to upper case letter conversion |