Skip to content

This is my custom library I made while studying at 1337 and that I will update over time as I study.

Notifications You must be signed in to change notification settings

alouane04/C-Library-Functions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📖 Libft
Personal home-made Library

💡 What is it?

This is my custom library I made while studying at 1337 and that I will update over time as I study.
Feel free to tell me your thoughts and if there's anything to improve it :)

📚 What is in?

There's a bunch of differents functions, which has been used througout the whole 42 cursus.
There is currently:

  • Libft
  • ft_printf
  • GetNextLine
  • Lots of extra functions
  • Feel free to discover theme one by one

📜 Side Notes

  • The goal of the library is to get to use the least amount of C standard library functions as possible!
  • If you are a student of 42 aswell and came for solutions, be aware some functions has been sightly modified
    for little extra handy features

C standard library

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.

Non-stantard C Library

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

Chained lists manipulation

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.

get_next_line

Libft Description
get_next_line Returns a line read from the file descriptor `fd`.
Returns NULL if there are no more characters to read, or if an error occured.

ft_printf

Libft Description
ft_printf This function mimics the real `printf` but is limited:
Supports these specifiers: 'cspdiuxX%'
Supports these flags: '-0#+ '.

some needed function

Libft Description
ft_2d_len It calc the lenght of 2D char table.
It take table to be calc and return lenght of it.
ft_free It free 2D char table.
It take table to be free and return void.
ft_strsep Locates, in the string referenced by `*str`,
the first occurrence of any character in the string `sep` (or the terminating '\0' character) and replaces it with a '\0'.
The location of the next character after the delimiter character (or NULL, if the end of the string was reached) is stored in `*str`.
The original value of `*str` is returned.
If `*str` is initially NULL, NULL is returned.
ft_strspn Compares at most `n` bytes from the two strings `s1` and `s2`.
It returns an integer less than, equal to, or greater than zero if `s1` is found, respectively, to be less than, to match, or be greater than s2.
If `n` is zero, the return value is zero.
ft_atoll Converts the initial part of the string `str` to a long long.
The string may begin with an arbitrary amount of white space followed by a single optional '+' or '-' sign.
The remainder of the string is converted to a long long in the obvious manner, stopping at the first character which is not a valid digit.
If an overflow occurs, LONG_LONG_MAX is returned and errno is set to ERANGE.
If an underflow occurs, LONG_LONG_MIN is returned and errno is set to ERANGE.