My implementation of some of the Standard C Library functions including some additional useful functions.
Libft is an individual project at 42 that requires us to re-create some C standard library functions including some additional ones that can be used later to build a library of useful functions for the rest of the program.
- Unix logic
- Algorithms & AI
- Imperative programming
- Rigor
Follow the steps below
# Clone the project and access the folder
git clone https://github.com/wwwwelton/libft && cd libft/
# Run Make so you can build the library
make
# Run Make with bonus if you want chained lists manipulation functions
make bonus
# Compile your main with the library, example:
clang main.c libft.a
# Execute your program
./a.out
# Clean output objects with
make fclean
# Well done!
Each functions has the prefix "ft_" which means forty two.
C Library <ctype.h> |
||
---|---|---|
Libft | Description | |
ft_isalnum | Checks whether the passed character is alphanumeric. | |
ft_isalpha | Checks whether the passed character is alphabetic. | |
ft_isascii | Checks whether the passed character is ASCII. | |
ft_isdigit | Checks whether the passed character is decimal digit. | |
ft_isprint | Checks whether the passed character is printable. | |
ft_tolower | Converts uppercase letters to lowercase. | |
ft_toupper | Converts lowercase letters to uppercase. | |
C Library <string.h> |
||
Libft | Description | |
ft_bzero | Erases the data in the n bytes of the memory block. (Write zeroes) | |
ft_memchr | Searches for the first occurrence of the character c (an unsigned char) in the first n bytes of the string. | |
ft_memcmp | Compares the first n bytes of str1 and str2. | |
ft_memcpy | Copies n characters from src to dest. | |
ft_memmove | Copies n characters from src to dest. (Non destructive manner) | |
ft_memset | Copies the character c (an unsigned char) to the first n characters of the string. | |
ft_strchr | Searches for the first occurrence of the character c (an unsigned char) in the string. | |
ft_strlcat | Appends string src to the end of dst. It will append at most dstsize - strlen(dst) - 1 characters. | |
ft_strlcpy | Copies up to dstsize - 1 characters from the string src to dst. | |
ft_strlen | Computes the length of the string but not including the terminating null character. | |
ft_strncmp | Compares at most the first n bytes of str1 and str2. | |
ft_strnstr | Locates the first occurrence of the null-terminated string little in the string big, where not more than len characters are searched. | |
ft_strrchr | Searches for the last occurrence of the character c (an unsigned char) in the string. | |
C Library <stdlib.h> |
||
Libft | Description | |
ft_atoi | Converts the string to an integer (type int). | |
ft_calloc | Allocates the requested memory initialized to zero bytes. | |
Libft | Description | |
ft_itoa | Converts the int to a string (type char *). | |
ft_putchar_fd | Outputs the character 'c' to the given file descriptor. | |
ft_putendl_fd | Outputs the string 's' to the given file descriptor, followed by a newline. | |
ft_putnbr_fd | Outputs the integer 'n' to the given file descriptor. | |
ft_putstr_fd | Outputs the string 's' to the given file descriptor. | |
ft_strdup | Returns a pointer to a null-terminated byte string, which is a duplicate of the string. | |
ft_striteri | Applies a function to each character of the string. | |
ft_strjoin | Returns a new string, which is the result of the concatenation of 's1' and 's2'. | |
ft_strmapi | Applies a function to each character of the string 's' to create a new string. | |
ft_strtrim | Returns a copy of 's1' with the characters specified in 'set' removed from the beginning and the end of the string. | |
ft_substr | Returns a substring from the string 's'. The substring begins at index 'start' and is of maximum size 'len'. | |
Libft | Description | |
ft_lstadd_back | Adds the element at the end of the list. | |
ft_lstadd_front | Adds the element at the beginning of the list. | |
ft_lstclear | Deletes and frees the given element and every successor of that element, using a given function and free. | |
ft_lstdelone | Takes as a parameter an element and frees the memory of the element’s content using a function given as a parameter and free the element. | |
ft_lstiter | Iterates the list and applies a function to the content of each element. | |
ft_lstlast | Returns the last element of the list. | |
ft_lstmap | Iterates the list and applies a function to the content of each element. Creates a new list resulting of the successive applications of the function. A 'del' function is used to delete the content of an element if needed. | |
ft_lstnew | Returns a new element. | |
ft_lstsize | Counts the number of elements in a list. | |
Libft | Description | |
ft_atol | Converts the string to a long integer (type long int). | |
ft_char_to_str | Creates a string of size len filled with the unsigned char passed as parameter. | |
ft_free_ptr | Deallocates a pointer memory address and sets to NULL. | |
ft_str_replace | Searches for the first occurrence of the string old_word in the string str and replaces with the string new_word. The memory address of the string str passed as a parameter will be freed. | |
ft_str_toupper | Converts lowercase letters of the string to uppercase. | |
ft_strmerge | Returns a new string, which is the result of the concatenation of 's1' and 's2'. The memory address of 's1' and 's2' will be freed. | |
ft_uitoa_base | Returns a string representing the unsigned integer in the base received as an argument. | |
ft_get_next_line | Return a string including \n if is a line. In case of the file dont have \n return a string without \n, NULL if the file is empty or error occurred. |
The project is updated regularly with new functions that could be useful for other projects.
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
Made by Welton Leite 👋 See my linkedin