ℹ️ A C static library with recoded standard functions
100/100 ✅
This project is about coding a C library.
It will contain a lot of general purpose functions your programs will rely upon.
42 makes us do this just so we can have a deeper understanding of data structures
and basic algorithms. At 42, certain standard libraries are prohibited in our projects, compelling us to continually expand our custom library with self-built functions as we advance in the program.
⚠️ Warning: Don't copy/paste code you don't understand: it's bad for you, and for the school.
ft_isalpha- alphabetic character test.ft_isdigit- decimal-digit character test.ft_isalnum- alphanumeric character test.ft_isascii- test for ASCII character.ft_isprint- printing character test (space character inclusive).ft_toupper- lower case to upper case letter conversion.ft_tolower- upper case to lower case letter conversion.
ft_memset- write a byte to a byte string.ft_strlen- find length of string.ft_bzero- write zeroes to a byte string.ft_memcpy- copy memory area.ft_memmove- copy byte string.ft_strlcpy- size-bounded string copying.ft_strlcat- size-bounded string concatenation.ft_strchr- locate character in string (first occurrence).ft_strrchr- locate character in string (last occurence).ft_strncmp- compare strings (size-bounded).ft_memchr- locate byte in byte string.ft_memcmp- compare byte string.ft_strnstr- locate a substring in a string (size-bounded).ft_strdup- save a copy of a string (with malloc).
ft_substr- extract substring from string.ft_strjoin- concatenate two strings into a new string (with malloc).ft_strtrim- trim beginning and end of string with the specified characters.ft_split- split string, with specified character as delimiter, into an array of strings.ft_itoa- convert integer to ASCII string.ft_strmapi- create new string from modifying string with specified function.ft_striteri- applies a provided function to each character in a string.ft_putchar_fd- output a character to given file.ft_putstr_fd- output string to given file.ft_putendl- output string to stdout with newline.ft_putnbr_fd- output integer to given file.
- Most of the the files and function names are namespaced with an ft in front. It stands for Forty Two
It aims to create a library called libft.a from the source files.
To create this library, clone the project:
git clone git@github.com:Bruno0798/42_libft.git
Enter the repository:
cd libft
Run Make (to run the Makefile that will compile the source code and create the library):
make
You should see a libft.a file and some object files (.o).
Now to clean up (removing the .o files), call make clean:
make clean
Now you just have to add this header at your .c files and use the Libft functions:
#include "libft.h"
If you try to compile your .c files with clang using clang example.c you will get an undefined symbol error for Libft functions.
You have to tell the file where your library resides:
clang example.c libft.a
That's it. Now run it using ./a.out
make - Compile libft mandatory files.
make clean - Delete all .o (object files) files.
make fclean - Delete all .o (object file) and .a (executable) files.
make re - Use rules fclean + all.
At 42 School, aligning to the 42 Norms, the school's coding standard, is a fundamental expectation for all projects.
