Development repo of my very own standard library
Start date: 15/july/2021
Project status: completed 122/100 points
The aim of this project is to re-code my own library with standard functions of the C library
libc
as well as some utility functions for memory and string manipulation. The bonus functions cover list manipulation.1
Requirements
All functions must have the same prototypes and implement the same behaviours as the originals. They must comply with the way they are defined in their man. All functions shall begin with the 'ft_' prefix.
Key learning points
- Handling different variable types and memory allocation
- Passing on various types of input and typecasting void pointers
- Setting up a Makefile to compile my library
- Familiarise myself with linked lists
ft_isalpha
- tests for alphabetic characterft_isdigit
- tests for decimal-digit characterft_isalnum
- tests for alphanumeric characterft_isascii
- tests for ASCII characterft_isprint
- tests for printable characters
ft_toupper
- converts lower case to upper caseft_tolower
- converts upper case to lower caseft_putchar_fd
- writes one character to given file descriptorft_putstr_fd
- writes a string to the given file descriptorft_putendl_fd
- writes a string and newline to the given file descriptorft_putnbr_fd
- writes an integer to the given file descriptor
ft_memset
- writes a byte to a byte stringft_memmove
- copies bytes from string to anotherft_memcpy
- copies bytes from src to dst memory areaft_memchr
- locates first occurence of byte in byte stringft_memcmp
- compares two byte strings
ft_strlen
- returns the length of a stringft_strlcpy
- size-bound string copyingft_strlcat
- appends string src to string dstft_strchr
- locates first occurence of a character in stringft_strrchr
- locates last occurence of a character in stringft_strncmp
- compares lexicographically two stringsft_strnstr
- locates a substring in a stringft_strdup
- saves a copy of a stringft_atoi
- converts a string to integer representation
ft_substr
- returns a substring from stringft_strjoin
- concatenates two stringsft_strtrim
- trims a string in regards to a reference setft_split
- splits a string and returns an arrayft_itoa
- allocates and returns a string of an integerft_strmapi
- creates new string resulting from successive application of function to each characterft_striteri
- applies a function to each character of a string
ft_lstnew
- allocates a new initialised list elementft_lstadd_front
- adds an element to the beginning of a listft_lstsize
- returns number of elements in listft_lstlast
- returns the last element of a listft_lstadd_back
- adds an elemenet to the end of a listft_lstdelone
- frees an element's content and elemente itselfft_lstclear
- deletes and frees the given element and every successorft_lstiter
- iterates list and applies function to elements
ft_free
- Frees a strings' memory and sets it to NULLft_strnjoin
- concatenates two strings but no more than set bytes
Clone the repository:
git clone https://github.com/KHammerschmidt/42cursus-Libft &&
cd libft
Create the library archive:
make
Add bonus functions to archive:
make bonus
To incoporate this library within a project add this line to your Makefile, adjust directory to project respectively.
make -C $(LIBFT_DIR)
Footnotes
-
This repo does not pass the initial moulinette tests of Libft at École 42 due to added functions and changes required by later projects. ↩