Skip to content

Personnal libft library, derived from 42 common core "Libft" project

Notifications You must be signed in to change notification settings

MaximeJC/Personnal_Libft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome on my personnal Libft

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).

1. Summary

List of functions

1. Ft_is

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 table
  • ft_isdigit: Check if a char is a digit (123)
  • ft_isinset: Check if a char is in a given char *set
  • ft_isnumber: Check if a char* is a valid number
  • ft_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 whitespaces
  • ft_iswhitespace: Check if a char is a whitespace (space ' ', new line '\n', cariage return '\r', etc.)

2. Ft_lst

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 list
  • ft_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 list
  • ft_lstclear: Clear every element of the list, setting its pointer to NULL
  • ft_lstdelone: Clear one element of a list. Doesn't relink the list between elements before and after
  • ft_lstiter: Apply a function passed in parameter to every element of the list
  • ft_lstlast: Get the last element of the list
  • ft_lstmap: Apply a function passed in parameter to every element of the list, setting results in a new list that is returned at the end
  • ft_lstnew: Create a new element, allocating memory space for its content
  • ft_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

3. Ft_math

Some useful math functions.

  • ft_max: Return the max value between two int
  • ft_min: Return the min value between two int
  • ft_pow: Return the result of a power^ operation

4. Ft_mem

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 parameters
  • ft_memcmp: Compare every bytes of two memory parts for n bytes
  • ft_memcpy: Copy a memory part into an other one
  • ft_memmove: Same as ft_memcpy but take care of the direction if a zone overlap the other
  • ft_memset: Turn every bytes of a string into the choosen character

5. Ft_misc

Some standalone functions that are still pretty useful.

  • ft_color_codes: Tool function ; Calling it print terminal color codes for strings in terminal
  • ft_printf: From the "ft_printf" project ; Recreate part of the printf function from the stdio.h library
  • get_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)

6. Ft_put

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 character
  • ft_putendl_fd: Print a string and add a new line after it
  • ft_putlnbr_fd: Print long number
  • ft_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 number
  • ft_putptr_fd: Print address of a pointer
  • ft_putstr_fd: Print a string

7. Ft_str

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 end
  • ft_strchr: Search a char into a string and return a pointer to its position
  • ft_strdup: Duplicate a string, allocating memory for it
  • ft_striteri: Apply a function given as parameter to every char of a string
  • ft_strjoin: Allocate some memory to create a new string, put two given string in it, and null-terminating the new string
  • ft_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 size
  • ft_strlcpy: Copy a string until size is reached into another, no matter it is empty or not
  • ft_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 len
  • ft_strlen: Return the size of a string passed as parameter
  • ft_strmapi: Same as ft_iteri, but apply the result to a newly allocated string that is returned
  • ft_strncmp: Compare two string until size is reached. Return 0 if they are the same, else return difference between char which differ
  • ft_strndup: Duplicate at max n bytes of a string, allocating memory for it
  • ft_strnstr: Search for a sub string into a bigger one
  • ft_strrchr: Same as ft_strchr but search begin from the end of the string
  • ft_strrncmp: Same as ft_strncmp but compare the end of the strings
  • ft_strsjoin: Based on ft_strjoin, takes every strings passed in arguments and join them together to return them as one full string
  • ft_strtrim: Trim given char set at the beginning and at the end from a string
  • ft_substr: Return a newly allocated string in the middle of a given bigger one

8. Ft_strtab

Function used to treat more easily string arrays.

  • ft_strtab_free: Fully free a string array passed as parameter
  • ft_strtab_size: Get the size of a string array

9. Ft_to

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 digits
  • ft_atol: Same as ft_atoi but return a long variable
  • ft_itoa: Turn an int into a string
  • ft_lst_to_strtab: Take a t_list and return a string tab with its content
  • ft_tolower: Turn every uppercase char of a string into lowercase one
  • ft_toupper: Turn every lowercase char of a string into uppercase one

About

Personnal libft library, derived from 42 common core "Libft" project

Topics

Resources

Stars

Watchers

Forks