Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/colmiik/libft
Beginner level library of replicated libc functions
https://github.com/colmiik/libft
42school libft
Last synced: about 1 month ago
JSON representation
Beginner level library of replicated libc functions
- Host: GitHub
- URL: https://github.com/colmiik/libft
- Owner: ColmiiK
- Created: 2023-09-11T13:59:01.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-02-19T15:23:54.000Z (12 months ago)
- Last Synced: 2024-11-08T19:14:09.083Z (3 months ago)
- Topics: 42school, libft
- Language: C
- Homepage:
- Size: 68.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This project is about coding a C library. It will contain a lot of general purpose functions your programs will rely upon.
---
# Mandatory part
Program name
libft.a
Turn in files
Makefile,libft.h
,*.c
Makefile
NAME, all, clean, fclean, re
External functions
Detailed below
Libft authorized
n/a
Descripción
Write your own library: a collection of functions
that will be a useful tool for your cursus.
## Technical considerations
- Declaring global variables is forbidden.
- If you need helper functions to split a more complex function, define them as static
functions. This way, their scope will be limited to the appropriate file.
- Place all your files at the root of your repository.
- Turning in unused files is forbidden.
- Every .c files must compile with the flags ``-Wall -Wextra -Werror``.
- You must use the command ar to create your library. Using the ``libtool`` command
is forbidden.
- Your ``libft.a`` has to be created at the root of your repository.## Part 1 - Libc functions
You must redo a set of functions from the libc. Your functions will have the
same prototypes and implement the same behaviors as the originals. They must comply
with the way they are defined in their man. The only difference will be their names. They
will begin with the ’``ft_``’ prefix. For instance, ``strlen`` becomes ``ft_strlen``.You must write your own function implementing the following original ones. They do
not require any external functions:
isalpha
isdigit
isalnum
isascii
isprint
strlen
memset
bzero
memcpy
memmove
strlcpy
strlcat
toupper
tolower
strchr
strrchr
strncmp
memchr
memcmp
strnstr
atoi
In order to implement the two following functions, you will use ``malloc()``:
- ``calloc``
- ``strdup``## Part 2 - Additional functions
In this second part, you must develop a set of functions that are either not in the libc,
or that are part of it but in a different form.
Nombre de la función
Descripción
ft_substr()
Allocates and returns a substring
ft_strjoin()
Allocates and returns a new string as a result of concatenation.
ft_strtrim()
Allocates and returns a copy of a string with all specified characters of a 'set' string removed from the beginning and end.
ft_split()
Allocates and returns an array of strings obtained by splitting a string by a delimiter.
ft_itoa()
Allocates and returns a string representing the integer recieved as an arguments. Negative numbers must be handled.
ft_strmapi()
Apply a function to all characters of a string.
ft_striteri()
Apply a function to all characters of a string with the index of a character
ft_putchar_fd()
Outputs a character to the specified file descriptor.
ft_putstr_fd()
Outputs a string to the specified file descriptor.
ft_putendl_fd()
Outputs a string to the specified file descriptor, adding a newline at the end.
ft_putnbr_fd()
Outputs a number to the specified file descriptor.
# Bonus part
Functions to manipulate memory and strings is very useful. But you will soon discover
that manipulating lists is even more useful.
You have to use the following structure to represent a node of your list. Add its
declaration to your ``libft.h`` file:```c
typedef struct s_list
{
void *content;
struct s_list *next;
} t_list;
```
The members of the t_list struct are:
- content: The data contained in the node.
``void *`` allows to store any kind of data.
- next: The address of the next node, or ``NULL`` if the next node is the last one.
In your Makefile, add a make bonus rule to add the bonus functions to your ``libft``.a.
Nombre de la función
Descripción
ft_lstnew()
Creates a new node with the specified content, pointingnext
toNULL
.
ft_lstadd_front()
Adds a new node 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()
Removes a node from the list.
ft_lstclear()
Deletes a list.
ft_lstiter()
Iterate through the list and apply a function to each node.
ft_lstmap()
Iterate through the list and apply a function to each node, deleting the progress if failed.