docs: adding documentation on my libft
This commit is contained in:
parent
c947e43e51
commit
83cc8419a0
47 changed files with 624 additions and 44 deletions
53
libft/.gitignore
vendored
Normal file
53
libft/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
to_do*
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
*.ko
|
||||
*.obj
|
||||
*.elf
|
||||
|
||||
# Linker output
|
||||
*.ilk
|
||||
*.map
|
||||
*.exp
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Libraries
|
||||
*.lib
|
||||
*.a
|
||||
*.la
|
||||
*.lo
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
*.su
|
||||
*.idb
|
||||
*.pdb
|
||||
|
||||
# Kernel Module Compile Results
|
||||
*.mod*
|
||||
*.cmd
|
||||
.tmp_versions/
|
||||
modules.order
|
||||
Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
||||
|
|
@ -6,14 +6,14 @@
|
|||
# By: rparodi <marvin@42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
|
||||
# Updated: 2024/10/31 17:19:36 by rparodi ### ########.fr #
|
||||
# Updated: 2024/10/31 18:17:13 by rparodi ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
# Variables
|
||||
|
||||
# Name
|
||||
NAME=../build/libft.a
|
||||
NAME = ../build/libft.a
|
||||
|
||||
# Commands
|
||||
CC = cc
|
||||
|
|
@ -32,6 +32,10 @@ LDLIBS = -lft
|
|||
|
||||
INCLUDES = ./includes/libft/
|
||||
|
||||
# Objects
|
||||
OBJDIRNAME = ../build
|
||||
OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.c=.o))
|
||||
|
||||
SRC = char/ft_isdigit.c \
|
||||
char/ft_isalnum.c \
|
||||
char/ft_isalpha.c \
|
||||
|
|
@ -81,10 +85,6 @@ SRC = char/ft_isdigit.c \
|
|||
str/ft_strtrim.c \
|
||||
str/ft_substr.c
|
||||
|
||||
# Objects
|
||||
OBJDIRNAME = ../build
|
||||
OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.c=.o))
|
||||
|
||||
# Colors
|
||||
GREEN = \033[32m
|
||||
GREY = \033[0;90m
|
||||
|
|
|
|||
7
libft/README.md
Normal file
7
libft/README.md
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
This project 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.
|
||||
##
|
||||
| Keywords | Skills |
|
||||
| ------|-----|
|
||||
| Unix Logic | Algorithms & AI |
|
||||
|| Imperative programming |
|
||||
|| Rigor |
|
||||
31
libft/includes/char.h
Normal file
31
libft/includes/char.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* char.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 14:54:04 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/31 15:22:26 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef CHAR_H
|
||||
# define CHAR_H
|
||||
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
# include <unistd.h>
|
||||
# include <limits.h>
|
||||
# include <fcntl.h>
|
||||
|
||||
int ft_isalnum(int c);
|
||||
int ft_isalpha(int c);
|
||||
int ft_isascii(int c);
|
||||
int ft_isdigit(int c);
|
||||
int ft_isprint(int c);
|
||||
int ft_tolower(int c);
|
||||
int ft_toupper(int c);
|
||||
|
||||
#endif
|
||||
27
libft/includes/convert.h
Normal file
27
libft/includes/convert.h
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* convert.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 14:57:24 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/31 15:27:40 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef CONVERT_H
|
||||
# define CONVERT_H
|
||||
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
# include <unistd.h>
|
||||
# include <limits.h>
|
||||
# include <fcntl.h>
|
||||
|
||||
char *ft_itoa(int n);
|
||||
int ft_atoi(const char *nptr);
|
||||
long long int ft_atoll(const char *nptr);
|
||||
|
||||
#endif
|
||||
23
libft/includes/libft.h
Normal file
23
libft/includes/libft.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* libft.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/06 11:14:57 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/31 15:27:14 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef LIBFT_H
|
||||
# define LIBFT_H
|
||||
|
||||
# include "char.h"
|
||||
# include "convert.h"
|
||||
# include "list.h"
|
||||
# include "memory.h"
|
||||
# include "print.h"
|
||||
# include "str.h"
|
||||
|
||||
#endif
|
||||
39
libft/includes/list.h
Normal file
39
libft/includes/list.h
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* list.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 15:00:12 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/31 15:27:20 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef LIST_H
|
||||
# define LIST_H
|
||||
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
# include <unistd.h>
|
||||
# include <limits.h>
|
||||
# include <fcntl.h>
|
||||
|
||||
typedef struct s_list
|
||||
{
|
||||
void *content;
|
||||
struct s_list *next;
|
||||
} t_list;
|
||||
|
||||
int ft_lstsize(t_list *lst);
|
||||
t_list *ft_lstlast(t_list *lst);
|
||||
t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *));
|
||||
t_list *ft_lstnew(void *content);
|
||||
void ft_lstadd_back(t_list **lst, t_list *new);
|
||||
void ft_lstadd_front(t_list **lst, t_list *new);
|
||||
void ft_lstclear(t_list **lst, void (*del)(void *));
|
||||
void ft_lstdelone(t_list *lst, void (*del)(void *));
|
||||
void ft_lstiter(t_list *lst, void (*f)(void *));
|
||||
|
||||
#endif
|
||||
31
libft/includes/memory.h
Normal file
31
libft/includes/memory.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* memory.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 15:18:17 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/31 15:21:00 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef MEMORY_H
|
||||
# define MEMORY_H
|
||||
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
# include <unistd.h>
|
||||
# include <limits.h>
|
||||
# include <fcntl.h>
|
||||
|
||||
int ft_memcmp(const void *s1, const void *s2, size_t n);
|
||||
void *ft_calloc(size_t nmemb, size_t size);
|
||||
void *ft_memchr(const void *s, int c, size_t n);
|
||||
void *ft_memcpy(void *dest, const void *src, size_t n);
|
||||
void *ft_memmove(void *dest, const void *src, size_t n);
|
||||
void *ft_memset(void *s, int c, size_t n);
|
||||
void ft_bzero(void *s, size_t n);
|
||||
|
||||
#endif
|
||||
31
libft/includes/print.h
Normal file
31
libft/includes/print.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* print.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 15:07:30 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/31 15:41:54 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef PRINT_H
|
||||
# define PRINT_H
|
||||
|
||||
# include <fcntl.h>
|
||||
# include <limits.h>
|
||||
# include <stdarg.h>
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# include <unistd.h>
|
||||
|
||||
int ft_dprintf(int fd, const char *s, ...);
|
||||
int ft_printf(const char *s, ...);
|
||||
void ft_putchar_fd(char c, int fd);
|
||||
void ft_putendl_fd(char *s, int fd);
|
||||
void ft_putnbr_fd(int n, int fd);
|
||||
void ft_putstr_fd(char *s, int fd);
|
||||
|
||||
#endif
|
||||
39
libft/includes/str.h
Normal file
39
libft/includes/str.h
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* str.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 15:04:59 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/31 16:15:39 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef STR_H
|
||||
# define STR_H
|
||||
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
# include <unistd.h>
|
||||
# include <limits.h>
|
||||
# include <fcntl.h>
|
||||
|
||||
char **ft_split(char const *s, char c);
|
||||
char *ft_strchr(const char *s, int c);
|
||||
char *ft_strcpy(char *dst, const char *src);
|
||||
char *ft_strdup(const char *s);
|
||||
char *ft_strjoin(char const *s1, char const *s2);
|
||||
char *ft_strmapi(char const *s, char (*f)(unsigned int, char));
|
||||
char *ft_strnstr(const char *big, const char *little, size_t len);
|
||||
char *ft_strrchr(const char *s, int c);
|
||||
char *ft_strtrim(char const *s1, char const *set);
|
||||
char *ft_substr(char const *s, unsigned int start, size_t len);
|
||||
int ft_strncmp(const char *s1, const char *s2, size_t n);
|
||||
size_t ft_strlcat(char *dst, const char *src, size_t size);
|
||||
size_t ft_strlcpy(char *dst, const char *src, size_t size);
|
||||
size_t ft_strlen(const char *s);
|
||||
void ft_striteri(char *s, void (*f)(unsigned int, char*));
|
||||
|
||||
#endif
|
||||
|
|
@ -6,12 +6,18 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/12 11:39:56 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/12 17:11:53 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:29:37 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Add the list new to the back of chained list of lst
|
||||
*
|
||||
* @param lst first element of the list
|
||||
* @param new The element to add at the end
|
||||
*/
|
||||
void ft_lstadd_back(t_list **lst, t_list *new)
|
||||
{
|
||||
t_list *tempo;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,18 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/12 11:40:16 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/12 17:14:33 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:30:01 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Add the list new to the front of chained list of lst
|
||||
*
|
||||
* @param lst first element of the list
|
||||
* @param new The element to add at the start
|
||||
*/
|
||||
void ft_lstadd_front(t_list **lst, t_list *new)
|
||||
{
|
||||
if (*lst == NULL)
|
||||
|
|
|
|||
|
|
@ -6,12 +6,18 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/12 11:40:37 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/12 19:34:19 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:32:23 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Clear the all list with the function
|
||||
*
|
||||
* @param lst the start of the chained list
|
||||
* @param del the function to clear the list
|
||||
*/
|
||||
void ft_lstclear(t_list **lst, void (*del)(void *))
|
||||
{
|
||||
t_list *tempo;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,18 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/12 11:42:11 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/12 18:10:40 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:46:00 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Clear the element of the list with the function
|
||||
*
|
||||
* @param lst the element of the list to be clear
|
||||
* @param del the function to clear the list
|
||||
*/
|
||||
void ft_lstdelone(t_list *lst, void (*del)(void *))
|
||||
{
|
||||
del(lst->content);
|
||||
|
|
|
|||
|
|
@ -6,12 +6,18 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/12 11:42:24 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/12 18:07:02 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:46:55 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Apply the function given in arguments at all the element of the list
|
||||
*
|
||||
* @param lst the chained list
|
||||
* @param f the pointer to function
|
||||
*/
|
||||
void ft_lstiter(t_list *lst, void (*f)(void *))
|
||||
{
|
||||
while (lst != NULL)
|
||||
|
|
|
|||
|
|
@ -6,12 +6,18 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/12 11:42:54 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/12 17:25:48 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:48:08 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Found the last element of the chained list
|
||||
*
|
||||
* @param lst the chained list
|
||||
* @return the last element of the chained list
|
||||
*/
|
||||
t_list *ft_lstlast(t_list *lst)
|
||||
{
|
||||
if (lst == NULL)
|
||||
|
|
|
|||
|
|
@ -6,12 +6,20 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/12 11:43:28 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/12 19:28:02 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:51:38 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Create an other list from an old one with a function on all element
|
||||
*
|
||||
* @param lst the chained list
|
||||
* @param f the function to function to iterate
|
||||
* @param del The function to delete the old list
|
||||
* @return
|
||||
*/
|
||||
t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *))
|
||||
{
|
||||
t_list *tempo;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,18 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/12 11:44:02 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/12 14:25:12 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:52:24 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Allocate a new list with the first element
|
||||
*
|
||||
* @param content the element to give on first element
|
||||
* @return the new list
|
||||
*/
|
||||
t_list *ft_lstnew(void *content)
|
||||
{
|
||||
t_list *to_return;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,18 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/12 11:44:24 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/13 12:22:02 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:53:11 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Give the size of the chained list
|
||||
*
|
||||
* @param lst the chained list
|
||||
* @return the size of the list
|
||||
*/
|
||||
int ft_lstsize(t_list *lst)
|
||||
{
|
||||
int count;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,18 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:43:13 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/07 17:25:28 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:54:25 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Sets a block of memory to zero
|
||||
*
|
||||
* @param s Pointer to the memory area to be set at zero
|
||||
* @param n Number of bytes to set to zero
|
||||
*/
|
||||
void ft_bzero(void *s, size_t n)
|
||||
{
|
||||
ft_memset(s, 0, n);
|
||||
|
|
|
|||
|
|
@ -6,12 +6,18 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:47:17 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/13 14:47:17 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:55:30 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Allocates and zeroes memory for an array
|
||||
*
|
||||
* @param nmemb Number of elements to allocate
|
||||
* @param size Size of each element in bytes
|
||||
*/
|
||||
void *ft_calloc(size_t nmemb, size_t size)
|
||||
{
|
||||
size_t total;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,22 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:48:30 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/07 18:45:57 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:59:07 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Scans memory for a byte
|
||||
*
|
||||
* @param s Pointer to the memory area to scan
|
||||
* @param c Byte value to search for
|
||||
* @param n Number of bytes to scan in s
|
||||
*
|
||||
* @return A pointer to the matching byte in memory, or NULL if the byte
|
||||
is not found within the first n bytes
|
||||
*/
|
||||
void *ft_memchr(const void *s, int c, size_t n)
|
||||
{
|
||||
size_t i;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,24 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:49:04 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/07 18:46:15 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:59:48 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Compares two memory blocks
|
||||
*
|
||||
* @param s1 Pointer to the first memory area
|
||||
* @param s2 Pointer to the second memory area
|
||||
* @param n Number of bytes to compare
|
||||
*
|
||||
* @return An integer indicating the relationship between the two memory areas:
|
||||
* - `< 0` if `s1` is less than `s2`
|
||||
* - `0` if `s1` equals `s2`
|
||||
* - `> 0` if `s1` is greater than `s2`
|
||||
*/
|
||||
int ft_memcmp(const void *s1, const void *s2, size_t n)
|
||||
{
|
||||
size_t i;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,21 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:49:46 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/13 19:14:23 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:57:31 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Copies memory from source to destination
|
||||
*
|
||||
* @param dest Pointer to the destination memory area
|
||||
* @param src Pointer to the source memory area
|
||||
* @param n Number of bytes to copy from src to dest
|
||||
*
|
||||
* @return A pointer to the destination memory area dest
|
||||
*/
|
||||
void *ft_memcpy(void *dest, const void *src, size_t n)
|
||||
{
|
||||
char *d;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:51:35 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/13 19:55:40 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:15:19 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -37,6 +37,15 @@ char *ft_checks(char *s, char *d, size_t n)
|
|||
return (d);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Copies memory with overlap handling
|
||||
*
|
||||
* @param dest Pointer to the destination memory area
|
||||
* @param src Pointer to the source memory area
|
||||
* @param n Number of bytes to copy from src to dest
|
||||
*
|
||||
* @return A pointer to the destination memory area dest
|
||||
*/
|
||||
void *ft_memmove(void *dest, const void *src, size_t n)
|
||||
{
|
||||
char *d;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,21 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:50:29 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/07 18:58:02 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 17:56:59 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Fills a block of memory with a specified byte
|
||||
*
|
||||
* @param s Pointer to the memory area to fill
|
||||
* @param c Byte value to be set in the memory
|
||||
* @param n Number of bytes to be set to the value c
|
||||
*
|
||||
* @return A pointer to the memory area s
|
||||
*/
|
||||
void *ft_memset(void *s, int c, size_t n)
|
||||
{
|
||||
char *str;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/14 17:27:44 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/31 16:12:37 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:01:28 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -43,6 +43,13 @@ int _check_args(int fd, char c, va_list args, int *ret_value)
|
|||
return (1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Print on a file descriptor
|
||||
*
|
||||
* @param fd the file descriptor
|
||||
* @param s the string
|
||||
* @return the number of character printable
|
||||
*/
|
||||
int ft_dprintf(int fd, const char *s, ...)
|
||||
{
|
||||
size_t i;
|
||||
|
|
@ -69,6 +76,12 @@ int ft_dprintf(int fd, const char *s, ...)
|
|||
return (ret_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Print on the standard output
|
||||
*
|
||||
* @param s the string
|
||||
* @return the number of character printable
|
||||
*/
|
||||
int ft_printf(const char *s, ...)
|
||||
{
|
||||
size_t i;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,18 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:58:22 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/10 15:31:57 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:02:37 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief print an character on a file descriptor
|
||||
*
|
||||
* @param c the character to print
|
||||
* @param fd the file descriptor
|
||||
*/
|
||||
void ft_putchar_fd(char c, int fd)
|
||||
{
|
||||
write(fd, &c, 1);
|
||||
|
|
|
|||
|
|
@ -6,12 +6,18 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:59:01 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/10 15:57:53 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:03:47 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Print a string follow by a new line on a file descriptor
|
||||
*
|
||||
* @param s the string to print
|
||||
* @param fd the file descriptor
|
||||
*/
|
||||
void ft_putendl_fd(char *s, int fd)
|
||||
{
|
||||
ft_putstr_fd(s, fd);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:59:18 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/13 20:13:20 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:04:17 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -39,6 +39,12 @@ static int ft_check_sign(int n, char *str, size_t *i, int fd)
|
|||
return (n);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Print a number on a file descriptor
|
||||
*
|
||||
* @param n the number to print
|
||||
* @param fd the file descriptor
|
||||
*/
|
||||
void ft_putnbr_fd(int n, int fd)
|
||||
{
|
||||
size_t i;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,18 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:58:46 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/10 15:57:46 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:05:11 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief print a string on a file descriptor
|
||||
*
|
||||
* @param s the string to print
|
||||
* @param fd the file descriptor
|
||||
*/
|
||||
void ft_putstr_fd(char *s, int fd)
|
||||
{
|
||||
write(fd, s, ft_strlen(s));
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:56:02 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/13 12:14:57 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:13:39 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -74,6 +74,15 @@ static char **ext_w(char **words_array, const char *str, char sep, int size)
|
|||
return (words_array);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Splits a string into an array of substrings based on a delimiter.
|
||||
*
|
||||
* @param s The string to split.
|
||||
* @param c The delimiter character.
|
||||
*
|
||||
* @return A NULL-terminated array of substrings,
|
||||
* or NULL if memory allocation fails.
|
||||
*/
|
||||
char **ft_split(char const *s, char c)
|
||||
{
|
||||
int size;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,21 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:32:19 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/09 12:08:01 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:13:01 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Locates the first occurrence of a character in a string.
|
||||
*
|
||||
* @param s The string to search.
|
||||
* @param c The character to locate.
|
||||
*
|
||||
* @return A pointer to the matched character,
|
||||
* or NULL if it does not appear in `s`.
|
||||
*/
|
||||
char *ft_strchr(const char *s, int c)
|
||||
{
|
||||
unsigned int i;
|
||||
|
|
|
|||
|
|
@ -1,17 +1,28 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* strcmp.c :+: :+: :+: */
|
||||
/* ft_strcmp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:56:56 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/31 17:05:03 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:07:20 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Compares two strings lexicographically.
|
||||
*
|
||||
* @param s1 The first string to compare.
|
||||
* @param s2 The second string to compare.
|
||||
*
|
||||
* @return An integer indicating the relationship between the two strings:
|
||||
* - `< 0` if `s1` is less than `s2`.
|
||||
* - `0` if `s1` equals `s2`.
|
||||
* - `> 0` if `s1` is greater than `s2`.
|
||||
*/
|
||||
int ft_strcmp(const char *s1, const char *s2)
|
||||
{
|
||||
size_t i;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,20 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 16:14:10 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/31 16:15:46 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:14:03 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Copies a string.
|
||||
*
|
||||
* @param dst The destination buffer.
|
||||
* @param src The source string.
|
||||
*
|
||||
* @return A pointer to `dst`.
|
||||
*/
|
||||
char *ft_strcpy(char *dst, const char *src)
|
||||
{
|
||||
size_t i;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,20 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:53:59 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/13 20:02:09 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:14:44 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Duplicates a string.
|
||||
*
|
||||
* @param s1 The string to duplicate.
|
||||
*
|
||||
* @return A pointer to the duplicated string,
|
||||
* or NULL if memory allocation fails.
|
||||
*/
|
||||
char *ft_strdup(const char *s)
|
||||
{
|
||||
size_t len;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,20 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:57:34 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/11 17:26:00 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:11:04 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Applies a function to each character of a string.
|
||||
*
|
||||
* @param s The string to modify.
|
||||
* @param f The function to apply to each character.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void ft_striteri(char *s, void (*f)(unsigned int, char*))
|
||||
{
|
||||
size_t i;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,21 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:55:15 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/09 17:47:46 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:13:21 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Joins two strings into a new string.
|
||||
*
|
||||
* @param s1 The first string.
|
||||
* @param s2 The second string.
|
||||
*
|
||||
* @return A pointer to the new concatenated string,
|
||||
* or NULL if memory allocation fails.
|
||||
*/
|
||||
char *ft_strjoin(char const *s1, char const *s2)
|
||||
{
|
||||
size_t i;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/08 22:28:26 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/12 11:45:52 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:10:19 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -22,6 +22,15 @@ static size_t ft_strnlen(char *dest, size_t size)
|
|||
return (i);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Appends a string with size limit.
|
||||
*
|
||||
* @param dst The destination buffer.
|
||||
* @param src The source string.
|
||||
* @param size The size of the destination buffer.
|
||||
*
|
||||
* @return The total length of the string it tried to create.
|
||||
*/
|
||||
size_t ft_strlcat(char *dest, const char *src, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,21 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:55:25 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/13 19:16:30 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:12:13 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Copies a string with size limit.
|
||||
*
|
||||
* @param dst The destination buffer.
|
||||
* @param src The source string.
|
||||
* @param size The maximum number of characters to copy.
|
||||
*
|
||||
* @return The total length of `src`.
|
||||
*/
|
||||
size_t ft_strlcpy(char *dst, const char *src, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,19 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:56:24 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/08 12:37:09 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:12:19 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Computes the length of a string.
|
||||
*
|
||||
* @param s The input string.
|
||||
*
|
||||
* @return The number of characters in the string `s`.
|
||||
*/
|
||||
size_t ft_strlen(const char *s)
|
||||
{
|
||||
size_t i;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,21 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:56:57 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/13 19:49:30 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:14:29 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Applies a function to each character of a string.
|
||||
*
|
||||
* @param s The input string.
|
||||
* @param f The function to apply to each character.
|
||||
*
|
||||
* @return A pointer to the newly created string,
|
||||
* or NULL if memory allocation fails.
|
||||
*/
|
||||
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
|
||||
{
|
||||
size_t i;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,21 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:56:56 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/09 13:16:39 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:13:58 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Compares two strings up to a specified number of characters.
|
||||
*
|
||||
* @param s1 The first string to compare.
|
||||
* @param s2 The second string to compare.
|
||||
* @param n The maximum number of characters to compare.
|
||||
*
|
||||
* @return An integer indicating the relationship between the two strings.
|
||||
*/
|
||||
int ft_strncmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
size_t i;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,26 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:57:44 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/13 19:17:49 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:12:05 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Locates a substring within a string, up to a specified length.
|
||||
*
|
||||
* The `ft_strnstr` function locates the first occurrence of the null-terminated
|
||||
* string `needle` within the string `haystack`,
|
||||
* searching only up to `len` characters.
|
||||
*
|
||||
* @param big The string to search.
|
||||
* @param little The substring to locate.
|
||||
* @param len The maximum number of characters to search.
|
||||
*
|
||||
* @return A pointer to the beginning of the located substring,
|
||||
* or NULL if `needle` is not found.
|
||||
*/
|
||||
char *ft_strnstr(const char *big, const char *little, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,21 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:58:22 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/11 18:46:54 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:13:53 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Locates the last occurrence of a character in a string.
|
||||
*
|
||||
* @param s The string to search.
|
||||
* @param c The character to locate.
|
||||
*
|
||||
* @return A pointer to the matched character,
|
||||
* or NULL if it does not appear in `s`.
|
||||
*/
|
||||
char *ft_strrchr(const char *s, int c)
|
||||
{
|
||||
size_t i;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,20 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:55:44 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/13 20:08:51 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:09:25 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Trims specified characters from the start and end of a string.
|
||||
*
|
||||
* @param s1 The string to trim.
|
||||
* @param set The set of characters to remove.
|
||||
*
|
||||
* @return A pointer to the trimmed string, or NULL if memory allocation fails.
|
||||
*/
|
||||
char *ft_strtrim(char const *s1, char const *set)
|
||||
{
|
||||
size_t i;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,21 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:54:42 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/13 20:08:02 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 18:10:59 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
/**
|
||||
* @brief Extracts a substring from a string.
|
||||
*
|
||||
* @param s The source string.
|
||||
* @param start The starting index of the substring.
|
||||
* @param len The maximum length of the substring.
|
||||
*
|
||||
* @return A pointer to the substring, or NULL if memory allocation fails.
|
||||
*/
|
||||
char *ft_substr(char const *s, unsigned int start, size_t len)
|
||||
{
|
||||
char *str;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue