pedromessetti / libft

My very first own library!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LIBFT

Index

Description ๐Ÿ“‹

Libft is my own C library with useful functions coded by myself that I will use during my course. This project was about understanding the way these general purpose functions work, implementing and learning to use them. Is a very helpfull librarie since I use it in almost all of my 42 projects.

External functions used: write(), malloc() and free().

For more information about the project check the subject here. The library and functions were written following the rules described in the 42 Norme. To check the Norme click here.

Functions ๐Ÿ”ง

Name Description Parameters Return value
ft_strdup Allocates memory for a new string that is a duplicate of string s. String to be duplicated. Pointer to a new string which is a duplicate of the string s. NULL if memory allocation fails or if s is empty.
ft_strlen Calculates the length of the string pointed to by s, excluding the terminating null byte ('\0'). Source string. The lenght of string s.
ft_strjoin Allocates memory with malloc() for a new string that is the concatenation of s1 and s2. Strings to be concateneted. The new string (s1 + s2). NULL if the allocation fails.
ft_strlcpy Copies up to size - 1 characters from the NULL-terminated src to dst, NULL-terminating the result. Source string. Destination string. Size of the copy. The length of src.
ft_strlcat Concatenate src string and dst string. It will append at most size - strlen(dst) - 1 bytes, NULL-terminating the result. Source string. Destination string. Size of the copy. The initial length of dst + the length of src.
ft_strchr Search for char c and returns a pointer for his first occurrence. String to be searched. Char for searching. Pointer to the first occurrence of the char c in the str. NULL if the character is not found.
ft_strrchr Search for char c and returns a pointer for his last occurrence. String to be searched. Char for searching. Pointer to the last occurrence of the char c in the str. NULL if the character is not found.
ft_strncmp Compares only the first n bytes of s1 and s2. Strings to be compared. Int less than, equal to, or greater than zero if s1 is found in than s2.
ft_strtrim Allocates memory with malloc() and returns a copy of s1 with the characters specified in โ€™setโ€™ removed from the beginning and the end of the string String to be copied. Set to be removed. Copy of s1 with the characters specified in โ€™setโ€™ removed from the beginning and the end of the string. NULL if the allocation fails.
ft_strnstr Locates the first occurrence of the null-terminated str little in the str big, where not more than len char are searched. Source string. Target string to be found. Len to be searched. Pointer to the first char of the first occurrence of little. If little occurs nowhere in big, NULL is returned. If little is empty, big is returned.
ft_substr Allocates memory with malloc() and returns a substring from the str s. The substring begins at index โ€™startโ€™ and is of maximum size len. Source string. Start index. Maximum size len. Substring. NULL if the allocation fails.
ft_split Allocates memory with malloc() and returns an array of strings obtained by splitting string s using the character c as a delimiter. The array ends with a NULL pointer. Source string. Delimiter character. Array of strings. NULL if the allocation fails.
ft_strmapi Applies the function โ€™fโ€™ to each char of the string s, and passing its index as first argument to create a new string with malloc() resulting from successive applications of โ€™fโ€™. Source string. Function to apply. The new string created from the successive applications of โ€™fโ€™. NULL if the allocation fails.
ft_striteri Applies the function โ€™fโ€™ on each char of the string passed as argument, passing its index as first argument. Each char is passed by address to โ€™fโ€™ to be modified if necessary. Source string. Function to apply. None.
ft_str_is_space Check if the string is made only with spaces or tabs. Source string. 1 if the str has only spaces or tabs. 0 if the str has other chars.

Author


Pedro Vinicius Messetti

About

My very first own library!


Languages

Language:C 97.3%Language:Makefile 2.7%