https://github.com/aaron-22766/42_libft
Writing my own library of functions from the C standard libraries
https://github.com/aaron-22766/42_libft
42 42-libft 42born2code 42heilbronn 42projects 42school c c-library
Last synced: 20 days ago
JSON representation
Writing my own library of functions from the C standard libraries
- Host: GitHub
- URL: https://github.com/aaron-22766/42_libft
- Owner: aaron-22766
- Created: 2022-11-24T08:00:08.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-02-22T11:57:28.000Z (over 2 years ago)
- Last Synced: 2025-11-21T10:04:25.125Z (8 months ago)
- Topics: 42, 42-libft, 42born2code, 42heilbronn, 42projects, 42school, c, c-library
- Language: C
- Homepage:
- Size: 80.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
LIBFT
Your very first own library
---
## π£ About
This project is about coding a C library. It will contain a lot of general purpose functions your programs will rely upon. It is your very first project as a student at 42. You will need to recode a few functions of the C standard library as well as some other utility functions that you will use during your whole cursus.
## π Usage
### Requirements
The library is written in C language and thus needs the **`gcc` compiler** and some standard **C libraries** to run.
### Instructions
**1. Compiling the library**
To compile the library, run:
```shell
$ cd path/to/libft && make
```
**2. Using it in your code**
To use the library functions in your code, simply include its header:
```C
#include "libft.h"
```
**3. Link your program with libft.a**
```Makefile
LIBFT_DIR = path/to/libft
LIBFT = $(LIBFT_DIR)/libft.a
$(NAME): $(LIBFT)
gcc $(LIBFT) $(MY_SRCS)...
$(LIBFT):
make -C $(LIBFT_DIR)
```
## π¬ Description
### string
| Function | Description |
|--------------------|-----------------------------------------------------------------------------------------------------------------------|
| ft_strlen | Computes the length of the string βsβ. (not protected) |
| ft_strlcpy | Copies βsrcβ to βdstβ |
| ft_strlcat | Concatenates βsrcβ to βdstβ |
| ft_strchr | Locates the first occurrence of the character βcβ in the string βsβ |
| ft_strrchr | Locates the last occurrence of the character βcβ in the string βsβ |
| ft_strcmp | Compares the two strings βs1β and βs2β |
| ft_strncmp | Compares βnβ characters of the two strings βs1β and βs2β |
| ft_strncpy | Copies at most βlenβ characters from βsrcβ to βdstβ |
| ft_strnstr | Locates the first occurrence of βneedleβ in βhaystackβ, within βlenβ characters |
| ft_strdup | Allocates a copy of βs1β |
| ft_substr | Allocates a sub-string from the string βsβ |
| ft_strjoin | Allocates new string, which is the result of the concatenation of βs1β and βs2β |
| ft_strtrim | Allocates a copy of βs1β with all characters specified in βsetβ removed from the beginning and the end of the string. |
| ft_split | Splits βsβ using the character βcβ as a delimiter |
| ft_strmapi | Applies the function βfβ to each character of βsβ, returning new string |
| ft_striteri | Applies the function βfβ on each character of βsβ |
### memory
| Function | Description |
|-------------------|-------------------------------------------------------------------------------------------------|
| ft_calloc | Allocates space for βcountβ elements that are βsizeβ bytes of memory, filled with zeroed bytes. |
| ft_memset | Writes βlenβ bytes of value βcβ to the array βbβ |
| ft_bzero | Writes βnβ zeroed bytes to the string βsβ |
| ft_memcpy | Copies βnβ bytes from memory area βsrcβ to memory area βdstβ |
| ft_memmove | Copies βlenβ bytes from string βsrcβ to string βdstβ (non-destructive manner) |
| ft_memchr | Searches for the first occurence of βcβ in βsβ within βnβ bytes |
| ft_memcmp | Compares byte string βs1β against byte string βs2β |
### print
| Function | Description |
|-----------------|--------------------------------------------------------------------------------|
| ft_putchar_fd | Outputs the character βcβ to the given file descriptor βfdβ |
| ft_putstr_fd | Outputs the string βsβ to the given file descriptor βfdβ |
| ft_putendl_fd | Outputs the string βsβ to the given file descriptor βfdβ followed by a newline |
| ft_putnbr_fd | Outputs the integer βnβ to the given file descriptor βfdβ |
### convert
| Function | Description |
|------------------------|-------------------------------------------------------------------------|
| ft_toupper | Converts a lower-case letter to the corresponding upper-case letter |
| ft_tolower | Converts a upper-case letter to the corresponding lower-case letter |
| ft_atoi | Converts the initial portion of βstrβ to int representation |
| ft_itoa | Converts the integer βnβ to string representation |
### check
| Function | Description |
|--------------------|------------------------------------------------------|
| ft_isalpha | Checks character for an alphabetic character |
| ft_isdigit | Checks character for a digit |
| ft_isalnum | Checks character for an alhabetic character or digit |
| ft_isprint | Checks character for a printable character |
| ft_isascii | Checks character for an ascii character |
### linked list (bonus)
| Function | Description |
|-----------------|--------------------------------------------------------------------------------------------------------|
| ft_lstnew | Allocates and returns a new node |
| ft_lstadd_front | Adds the node βnewβ at the beginning of the list |
| ft_lstsize | Counts the number of nodes in a list |
| ft_lstlast | Returns the last node of the list |
| ft_lstadd_back | Adds the node βnewβ at the end of the list |
| ft_lstdelone | Frees the memory of the nodeβs content using the function βdelβ given as a parameter and free the node |
| ft_lstclear | Deletes and frees the given node and every successor of that node, using the function βdelβ and free |
| ft_lstiter | Iterates the list βlstβ and applies the function βfβ on the content of each node |
| ft_lstmap | Creates a new list resulting of the successive applications of the function βfβ |