First project of the 42 Cursus that consists of the creation of a library that will contain existing functions, which I will have to replicate, and others of own creation.
To finish this project it is necessary to provide a .c file for each function created, an .h file containing all the headers and a Makefile that will compile the source files to the required output with the -Wall, -Werror and -Wextra flags.
To compile the library, you need to enter in the repository where libft is and run:
makeYou can remove the .o files with:
make cleanTo remove all the files generated by make:
make fcleanIn case that you want to use the library in your code, you need to include the header in your .c files:
#include "libft.h"Then you need to compile your main.c file with the libft.a file generated after compiling the library with make.
cc -Wall -Wextra -Werror main.c libft.aft_isalpha-> Checks if the character is alphabetic.ft_isdigit-> Checks if the character is a digit.ft_isalnum-> Checks if the character is alphanumeric.ft_isascii-> Checks if the character is ASCII.ft_isprint-> Checks if the character is printable.ft_toupper-> Converts the character to uppercase.ft_tolower-> Converts the character to lowercase.
ft_memset-> Fills the first n bytes of the memory area with the constant byte c.ft_memcpy-> Copies n bytes from a memory area. The memory areas must not overlap.ft_memmove-> Copies n bytes from a memory area. The memory areas may overlap.ft_memchr-> Locates the first occurrence of c in the initial n bytes of an object.ft_memcmp-> Compares the first n bytes of two objects.ft_strnstr-> Locate the first occurrence of a substring in a string.ft_strlen-> Displays the number of characters in a string.ft_strlcpy-> Copies a string of characters (including the null character), but no more than n - 1 characters.ft_strlcat-> Concatenate two strings, but no more than n - 1 characters.ft_strncmp-> Compares two strings, but no more than the first n characters.ft_strdup-> Returns a pointer to a new string which is a duplicate of the string. The memory is reserved withmalloc.ft_strchr-> Locates the first occurrence of c in a string.ft_strrchr-> Locates the last occurrence of c in a string.
ft_bzero-> Places n zero-valued bytes in the area pointed to by s.
ft_atoi-> Converts the beginning of a string to an integer.ft_calloc-> Allocates memory withmallocfor an array and returns a pointer to the allocated memory. The memory is set to zero.
ft_substr-> Reserves memory withmallocand returns a substring whose start and maximum length are given parameters.ft_strjoin-> Reserves memory withmallocand returns the concatenation of two strings.ft_strtrim-> Removes all characters contained in the string 'set' from the beginning and from the end of the string 's1', until a character not belonging to 'set' is found. The resulting string is returned with amallocreservation.ft_split-> Reserves memory withmallocfor an array of strings resulting from separating the string 's' into substrings using the character 'c' as delimiter. The array must end with a NULL pointer.ft_itoa-> Reserves memory withmallocand returns a string representing the integer received as argument.ft_strmapi-> To each character of the string 's', apply the functionfgiving as parameters the index within 's' and the character itself. It generates a new string (usingmalloc) with the result of the successive use off.ft_striteri-> To each character in the string 's', apply the functionfgiving as parameters the index within 's' and the address of the character itself, which may be modified if necessary.ft_putchar_fd-> Displays the character used as parameter.ft_putstr_fd-> Displays the characters of a string.ft_putendl_fd-> Displays the characters of a string with a line break at the end.ft_putnbr_fd-> Displays the number used as parameter.
The structure to represent a list node will be:
typedef struct s_list
{
void *content;
struct s_list *next;
} t_list;ft_lstnew-> Create a new node usingmalloc. The variable 'content' is initialized with the content of the parameter. The variable 'next', with NULL.ft_lstadd_front-> Adds the node 'new' to the beginning of the list.ft_lstsize-> Counts the number of nodes in a list.ft_lstlast-> Returns the last node in the list.ft_lstadd_back-> Adds the node 'new' to the end of the list.ft_lstdelone-> Takes as parameter a node and frees the memory of the content using the functiondelgiven as parameter, in addition to freeing the node. The memory of 'next' must not be freed.ft_lstclear-> Removes and frees the given node and all consecutive nodes, using thedelandfreefunction. At the end, the pointer to the list must be NULL.ft_lstiter-> Iterates the list and apply theffunction on the content of each node.ft_lstmap-> Iterates the list and applies the functionfto the content of each node. It creates a list resulting from the correct and successive application of the functionfon each node. Thedelfunction is used to remove the contents of a node.
- How to test the project? -> Francinette