Skip to content

qxxel/Libft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Libft

42 Project Language


📌 Summary


📖 About

Libft is a project of 42 school. It's about recoding a C library with many default functions like strlen or atoi. This project is the first of the Common Core in 42, who is usefull in many future projects.


✨ Functions

Function Man (link) Description
ft_atoi atoi transform ascii to int
ft_bzero bzero erases the data on the memory
ft_calloc calloc allocate memory and set all to NULL
ft_isalnum isalnum check if the ascii value is alpha or numeric
ft_isalpha isalpha check if the ascii value is alpha
ft_isascii isascii check if the value is ascii
ft_isdigit isdigit check if the ascii value is numeric
ft_isprint isprint check if the ascii value is printable
ft_itoa transform int to ascii (fonction perso)
ft_lstadd_back add an element at the end of a linked list
ft_lstadd_front add an element at the begin of a linked list
ft_lstclear clear a linked list
ft_lstdelone delete an element of a linked list
ft_lstiter apply a function on each element of a linked list
ft_lstlast return the last element of a linked list
ft_lstmap return a new linked list with transformed values
ft_lstnew create a list with a content
ft_lstsize return the size of the linked list
ft_memchr memchr scan memory until a char is found
ft_memcmp memcmp compare two memory areas
ft_memcpy memcpy copy memory (non-overlapping areas)
ft_memmove memmove copy memory (safe even if overlapping)
ft_memset memset fill memory with a byte value
ft_putchar_fd write write a char in a fd
ft_putendl_fd write a string with a newline in a fd (fonction perso)
ft_putnbr_fd write a number in a fd (fonction perso)
ft_putstr_fd write a string in a fd (fonction perso)
ft_split split a string at each iteration of a char (fonction perso)
ft_strchr strchr return pointer to first occurrence of a char in a string
ft_strdup strdup duplicate a string (malloc + copy)
ft_striteri apply a function on each char of string with its index (fonction perso)
ft_strjoin concatenate two strings into a new one (malloc)
ft_strlcat strlcat append string safely with size limit
ft_strlcpy strlcpy copy string safely with size limit
ft_strlen strlen return the size of the string
ft_strmapi create a new string where each char is transformed by a function (fonction perso)
ft_strncmp strncmp compare two strings up to n characters
ft_strnstr strstr find a substring in a string, up to n chars
ft_strrchr strrchr return pointer to last occurrence of a char in a string
ft_strtrim remove all characters from start/end of string that are in a charset (fonction perso)
ft_substr extract a substring from a string (fonction perso)
ft_tolower tolower transform uppercase in lowercase
ft_toupper toupper transform lowercase in uppercase

⚙️ Installation

1. Clone the repository

Clone the repository at the root of your project.

git clone git@github.com:qxxel/Libft.git;
cd Libft

2. Compile the project

make

🕹️ Utilisation

1. If you don't want to update the Libft or recompile each time

You have to use the .a that you get from the make to compile with your program who use this library.

Exemple: cc [your_file.c] libft/libft.a -o [your_project_name]

Then you can launch your program and use the Libft !

2. If you want to deeply connect your project with Libft

You can add some lines in your Makefile to compile the Libft with your project.

# Add variables
LIBFTDIR = Libft
LIBFT = $(LIBFTDIR)/libft.a

[...]

# Check Libft files to recompile only if it's usefull
LIBFT_SRC = $(wildcard $(LIBFTDIR)/*.c) $(wildcard $(LIBFTDIR)/**/*.c)
LIBFT_HDR = $(wildcard $(LIBFTDIR)/*.h) $(wildcard $(LIBFTDIR)/**/*.h)
LIBFT_DEPS = $(LIBFT_SRC) $(LIBFT_HDR)

[...]

# Add the Libft rule to call its Makefile
$(LIBFT): $(LIBFT_DEPS)
	$(MAKE) -C $(LIBFTDIR)

[...]

# Add the libft.a in the compilation of your project
$(NAME): [your_objects] $(LIBFT)
	$(CC) $(CFLAGS) [your_objects] $(LIBFT) -o $@

# Call the clean of the Libft's Makefile
clean:
	[...]
	$(MAKE) -C $(LIBFTDIR) clean

# Call the fclean of the Libft's Makefile
fclean: clean
	[...]
	$(MAKE) -C $(LIBFTDIR) $@

Then you can launch make at the root of your project to compile it with Libft. Don't forget to make another time if you modify a file in ./Libft/


📂 Directories structure

📂 Libft
 ┣ 📂 includes     → headers files (.h)
 ┣ 📂 srcs         → sources files (.c)
 ┃  ┣ 📂 checkers  → functions who check a char
 ┃  ┣ 📂 display   → functions that use write
 ┃  ┣ 📂 list      → functions that apply on list
 ┃  ┣ 📂 memory    → functions who use directly memory
 ┃  ┣ 📂 others    → functions who do not enter on others categories
 ┃  ┗ 📂 string    → functions that take string as arguments
 ┣ Makefile
 ┗ README.md

👤 Author

  • Axel – GitHub
  • 42 student - login: agerbaud

About

First project in 42. Recreation of a standard C library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors