This lib was created and is used during the 42' school common core. I will update it pretty often, adding multiple functions that are not in the Libft initial project, but that can be usefull for next ones (as long as I have to use it).
Functions used to determine if a variable is in a certain type or contain some. They all take a char and treat it as an int.
ft_isalnum: Check if a char is alphanumeric (abc, ABC, 123)ft_isalpha: Check if a char is alphabetic (abc, ABC)ft_isascii: Check if a char is in the ASCII tableft_isdigit: Check if a char is a digit (123)ft_isinset: Check if a char is in a given char *setft_isnumber: Check if a char* is a valid numberft_isprint: Check if a char is a printable character from the ASCII table (between space ' ' and '~')ft_isvalid_str: Check if a string is non null, and not only composed of whitespacesft_iswhitespace: Check if a char is a whitespace (space ' ', new line '\n', cariage return '\r', etc.)
Functions used for chained lists. The structure is findable in the header file.
ft_lstadd_back: Add the element passed in parameter at the end of the listft_lstadd_front: Add the element passed in parameter at the top of the list, updating the list pointer to the element as the new first element of the listft_lstclear: Clear every element of the list, setting its pointer toNULLft_lstdelone: Clear one element of a list. Doesn't relink the list between elements before and afterft_lstiter: Apply a function passed in parameter to every element of the listft_lstlast: Get the last element of the listft_lstmap: Apply a function passed in parameter to every element of the list, setting results in a new list that is returned at the endft_lstnew: Create a new element, allocating memory space for its contentft_lstsecondtolast: Get the second to last element (useful for example to set its next pointer to NULL when deleting the last element of the list)ft_lstsize: Get the size of the list
Some useful math functions.
ft_max: Return the max value between two intft_min: Return the min value between two intft_pow: Return the result of a power^ operation
Functions operating directly on memory. Operates on bytes.
ft_bzero: Turn every bytes of a string into the null character ('\0')ft_calloc: Allocate some memory and set all bytes to null character ('\0')ft_memchr: Search and return if found the beginning of a bytes sequence in a memory zone, both passed as parametersft_memcmp: Compare every bytes of two memory parts for n bytesft_memcpy: Copy a memory part into an other oneft_memmove: Same as ft_memcpy but take care of the direction if a zone overlap the otherft_memset: Turn every bytes of a string into the choosen character
Some standalone functions that are still pretty useful.
ft_color_codes: Tool function ; Calling it print terminal color codes for strings in terminalft_printf: From the "ft_printf" project ; Recreate part of the printf function from the stdio.h libraryget_next_line: From the "get_next_line" project ; Return the reading of a file descriptor (from a file or the terminal) line by line (one per function call)
Printing functions. The all take a file descriptor as parameter, the one where to print (in a file or in terminal). Some are used by ft_printf function. They all return the lenght of what was printed.
ft_putchar_fd: Print a single characterft_putendl_fd: Print a string and add a new line after itft_putlnbr_fd: Print long numberft_putnbr_base_fd: Take a base as parameter and print an unsigned long in the choosen base (binary, hexa, etc.)ft_putnbr_fd: Print int numberft_putptr_fd: Print address of a pointerft_putstr_fd: Print a string
Function that operate on strings. Most of them are based on string.h lib.
ft_split: Split a string at every given char into a string array that is returned at the endft_strchr: Search a char into a string and return a pointer to its positionft_strdup: Duplicate a string, allocating memory for itft_striteri: Apply a function given as parameter to every char of a stringft_strjoin: Allocate some memory to create a new string, put two given string in it, and null-terminating the new stringft_strlcat: Put a string at the end of another, assuming it as enough allocated space for it, until everything is copied, or the return string is above or egual to sizeft_strlcpy: Copy a string until size is reached into another, no matter it is empty or notft_strlen_char: Return the size of a string from its beginning to the first char c found. If none found, act like ft_strlen() and return string lenft_strlen: Return the size of a string passed as parameterft_strmapi: Same as ft_iteri, but apply the result to a newly allocated string that is returnedft_strncmp: Compare two string until size is reached. Return 0 if they are the same, else return difference between char which differft_strndup: Duplicate at max n bytes of a string, allocating memory for itft_strnstr: Search for a sub string into a bigger oneft_strrchr: Same as ft_strchr but search begin from the end of the stringft_strrncmp: Same as ft_strncmp but compare the end of the stringsft_strsjoin: Based on ft_strjoin, takes every strings passed in arguments and join them together to return them as one full stringft_strtrim: Trim given char set at the beginning and at the end from a stringft_substr: Return a newly allocated string in the middle of a given bigger one
Function used to treat more easily string arrays.
ft_strtab_free: Fully free a string array passed as parameterft_strtab_size: Get the size of a string array
Some transformation functions from libraries like stdlib.h or ctype.h.
ft_atoi: Return an int from a string. The string must have at most a '+' or '-' sign followed only by digitsft_atol: Same as ft_atoi but return a long variableft_itoa: Turn an int into a stringft_lst_to_strtab: Take a t_list and return a string tab with its contentft_tolower: Turn every uppercase char of a string into lowercase oneft_toupper: Turn every lowercase char of a string into uppercase one