Score: 125/100
Finished: 14.10.2024
libft is a library of C functions rewritten from the standard library, as well as some additional functions that can be useful for C projects.
libft is the first project in the Core-Curriculum within the "42" programming school, this is my interpretation of the assignment with some extra functions that I will add as needed.
To use libft, download the library in the root of your project using the following command line
git clone git@github.com:blueyaGIT/libft.gitgit clone https://github.com/blueyaGIT/libft.gitgh repo clone blueyaGIT/libftThis will create a directory called ``libft/`, enter with the command
cd libftOnce inside, create the static library libft.a with the following command
makelibft.a will be inside libft/, now you just need to compile your project including libft/libft.a and adding the header files that contain the functions you want to use, all header files are inside libft/h_files.
#include "libft/libft.h"The libft library includes the following functions (for more detailed information read the header file, it includes syntax, parameter description, notes, and more relevant information):
ft_printf(): Print astringincluding variables of different types.get_next_line(): Read the text of a file descriptor until acharacternis encountered or the end of the file is reached.
ft_toupper(): Transforms acharfrom lowercase to uppercase.ft_tolower(): Transforms acharfrom uppercase to lowercase.
ft_itoa(): Transforms anintvalue to itsstringcounterpart.
ft_lstnew(): Creates a new node typet_list.ft_lstadd_front(): Adds a node to the front of the list.ft_lstadd_back(): Adds a node to the end of the list.ft_lstsize(): Counts the number of nodes belonging to the list.ft_lstlast(): Scrolls down the list until the last member is reached.ft_lstdelone(): Deletes the contents of the node with the provided function, then frees the node withfree()from the standard library.ft_lstclear: Completely removes the list, using the provided function for the content andfree()to free each of the nodes.ft_lstiter(): Iterates the given function on each node of the list.ft_lstmap(): Iterate thef()function on each node in the list, saving the result in a new list, if something goes wrong, use thedel()function to remove the contents of the new nodes, andfree()to remove all nodes from the new list.
ft_calloc: Performs a dynamic memory allocation and initializes all values to 0.ft_free_n_null(): Check if the given pointer is different fromNULL, if so performfree()of the standard library and move thepointertoNULL.ft_close: Checks if thefile descriptoris valid, if so closes it usingclose()from the standard library.
ft_memchr: Searches for the first occurrence of the givencharacterwithin the described memory range.ft_memcmp(): Compares two memory ranges, returning0if they are equal,>0or<0if they are different.
ft_memset(): This function takes a memory block and sets it to the given value.ft_memcpy(): This function copies a source memory block to the destination address.ft_memmove(): This function is similar toft_memcpy(), but handles cases where the source and destination overlap.ft_memmove()avoids this problem by copying the data in an order that depends on the relationship between src and dest.ft_bzero(): Sets a memory block at the given address to 0.
ft_strchr(): Searches for the first occurrence of the givencharacterwithin thestring. If found, returns the address of that location. If not found, returnsNULL.ft_strrchr(): This function is similar toft_strchr(), but starts searching from the end of thestringsrc. It returns the address of the last place where thecharacterc appears. If not found, it returnsNULL`.ft_strncmp(): Compares the 2 given strings up toncharacters or until a difference is found. Returns the difference or0if they are equal.ft_strnstr(): This function searches for the first occurrence of thearrayneedlein thearrayhaystack, but does not search beyondlencharacters inhaystack. If it findsneedle, it returns the start address ofneedle. If not found, it returnsNULL.
ft_strlen(): Counts the number of characters in astring.ft_strlcpy(): Copies astringfrom source to destination up to a specified size.ft_strlcat(): Concatenates a sourcestringto the end of a destinationstring, up to a specified size.ft_atoi(): Converts astringto an integer.ft_strdup(): Creates a copy of astring.ft_substr(): Extracts a substring of a givenstringfrom a specified index with a given length.ft_strjoin(): Joins two strings into a newstring.ft_strtrim(): Removes the characters defined insetfrom the beginning and end of thestringsrc, and stores the result in a newstring.ft_split(): Splits astringinto astring arrayusing thecharcas delimiter.ft_strmapi(): Applies a function to each character of astringand stores the results in a newstring.ft_striteri(): Applies a function to each character in astring.
ft_isalpha(): Checks if the given character is a letter in theASCIItable.ft_isdigit(): Checks if the given character is a digit in theASCIItable.ft_isalnum(): Check if the given character is a letter or a digit in theASCIItable.ft_isascii(): Check if the given character is in theASCIItable.ft_isprint(): Check if the given character is printable according to theASCIItable.
ft_putchar_fd(): Writes acharto a given file descriptor.ft_putstr_fd(): Writes astringto a given file descriptor.ft_putendl_fd(): Writes astringfollowed by a newline to a given file descriptor.