Skip to content

alissonmarcs/Libft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Libft

This is my own standard library for C language! It is a first project of 42 and will be used in next projects. Every function is implemented in it own single file.

Functions

Funcion Description
ft_atoi Convert a string to int.
ft_itoa Convert int to a new string.
ft_calloc Alloc a array of nmemb elements with size bytes each.
ft_isalnum Return if c is alfabetical or numeric.
ft_isalpha Return if c is alfabetical.
ft_isascii Return if c is ascii.
ft_isdigit Return if c is digit.
ft_isprint Return if c is printable.
ft_tolower Convert a char to lower case.
ft_toupper Convert a char to upper case.
ft_memset Set byte c in first n bytes of a block memory.
ft_bzero Set 0 in first n bytes of a memory block.
ft_memchr Scans for c in first n bytes of a memory block, and return a pointer to it.
ft_memcpy Copy first n bytes of src to dest. If overlap occours, the result is undefined.
ft_memmove Copy first n bytes of src to dest. Treat ovarlap if it occours.
ft_memcmp Compare first n bytes of two block memory.
ft_putchar_fd Put char c in fd.
ft_putstr_fd Put string in fd.
ft_putendl_fd Put string in fd with new line character.
ft_putnbr_fd Put number in fd.
ft_strlen Return length of string *s.
ft_strchr Return a pointer to first occurrence of c in string.
ft_strrchr Return last occurrence of char c in string *s.
ft_strdup Duplicate a string.
ft_strlcpy Copy string *src to *dst.
ft_strlcat Concatenate two strings *dst and *src.
ft_strjoin Return a new string resulting of concatenation of *s1 and *s2.
ft_strncmp Compare first n bytes of two strings *s1 and *s2.
ft_strnstr Return a substring of a string.
ft_substr Return new substring of string *s.
ft_strtrim Return new string *s1 with it ends trimmed.
ft_split Split string in array of words.
ft_striteri Call a function f to every character in string *s.
ft_strmapi Map every char of string *s to a new string.

Bonus functions

Function Description
ft_lstnew Create a new node.
ft_lstadd_front Add a node at head of a list.
ft_lstadd_back Add a node at tail of a list.
ft_lstsize Return size of a list.
ft_lstlast Return last node of a list.
ft_lstdelone Delete one node.
ft_lstclear Delete a node and their sucessors.
ft_lstiter Call function f to every node in list.
ft_lstmap Map every node of a list in a new list.

How to use

Follow these commands to compile the library:

git clone https://github.com/alissonmarcs/Libft.git
cd Libft
make bonus

Compiling with make bonus you will be able to use linked-list functions.

Supposing you have a main() defined in a main.c that call one of the functions above, compile it as follows:

cc main.c libft.a

Of course, include libft.h in your main.c.