libft reformat
This commit is contained in:
117
Makefile
117
Makefile
@ -3,85 +3,92 @@
|
|||||||
# ::: :::::::: #
|
# ::: :::::::: #
|
||||||
# Makefile :+: :+: :+: #
|
# Makefile :+: :+: :+: #
|
||||||
# +:+ +:+ +:+ #
|
# +:+ +:+ +:+ #
|
||||||
# By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ #
|
# By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2023/11/01 11:03:22 by adjoly #+# #+# #
|
# Created: 2023/11/01 11:03:22 by adjoly #+# #+# #
|
||||||
# Updated: 2023/11/14 10:30:27 by adjoly ### ########.fr #
|
# Updated: 2024/02/04 15:03:34 by adjoly ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
NAME = libft.a
|
NAME = libft.a
|
||||||
|
|
||||||
CC = clang
|
CC = cc
|
||||||
|
|
||||||
SRCS = ft_atoi.c \
|
SRCS = is/ft_isalnum.c \
|
||||||
ft_bzero.c \
|
is/ft_isalpha.c \
|
||||||
ft_isalnum.c \
|
is/ft_isascii.c \
|
||||||
ft_isalpha.c \
|
is/ft_isdigit.c \
|
||||||
ft_isascii.c \
|
is/ft_isprint.c \
|
||||||
ft_isdigit.c \
|
lst/ft_lstadd_back.c \
|
||||||
ft_isprint.c \
|
lst/ft_lstadd_front.c \
|
||||||
ft_putchar_fd.c \
|
lst/ft_lstclear.c \
|
||||||
ft_putnbr_fd.c \
|
lst/ft_lstdelone.c \
|
||||||
ft_putstr_fd.c \
|
lst/ft_lstiter.c \
|
||||||
ft_strdup.c \
|
lst/ft_lstlast.c \
|
||||||
ft_memcpy.c \
|
lst/ft_lstmap.c \
|
||||||
ft_memset.c \
|
lst/ft_lstnew.c \
|
||||||
ft_memmove.c \
|
lst/ft_lstsize.c \
|
||||||
ft_strlcpy.c \
|
mem/ft_bzero.c \
|
||||||
ft_strlen.c \
|
mem/ft_calloc.c \
|
||||||
ft_substr.c \
|
mem/ft_memchr.c \
|
||||||
ft_tolower.c \
|
mem/ft_memcmp.c \
|
||||||
ft_toupper.c \
|
mem/ft_memcpy.c \
|
||||||
ft_strlcat.c \
|
mem/ft_memmove.c \
|
||||||
ft_strjoin.c \
|
mem/ft_memset.c \
|
||||||
ft_strncmp.c \
|
print/ft_putchar.c \
|
||||||
ft_itoa.c \
|
print/ft_putchar_fd.c \
|
||||||
ft_calloc.c \
|
print/ft_putendl_fd.c \
|
||||||
ft_memchr.c \
|
print/ft_putnbrbase.c \
|
||||||
ft_memcmp.c \
|
print/ft_putnbrbase_fd.c \
|
||||||
ft_strchr.c \
|
print/ft_putnbr.c \
|
||||||
ft_strrchr.c \
|
print/ft_putnbr_fd.c \
|
||||||
ft_strnstr.c \
|
print/ft_putstr.c \
|
||||||
ft_putendl_fd.c \
|
print/ft_putstr_fd.c \
|
||||||
ft_strtrim.c \
|
str/ft_atoi.c \
|
||||||
ft_split.c \
|
str/ft_itoa.c \
|
||||||
ft_strmapi.c \
|
str/ft_split.c \
|
||||||
ft_striteri.c \
|
str/ft_strchr.c \
|
||||||
|
str/ft_strdup.c \
|
||||||
SRCS_BONUS= ft_lstnew.c \
|
str/ft_striteri.c \
|
||||||
ft_lstadd_front.c \
|
str/ft_strjoin.c \
|
||||||
ft_lstsize.c \
|
str/ft_strlcat.c \
|
||||||
ft_lstlast.c \
|
str/ft_strlcpy.c \
|
||||||
ft_lstadd_back.c \
|
str/ft_strlen.c \
|
||||||
ft_lstdelone.c \
|
str/ft_strmapi.c \
|
||||||
ft_lstclear.c \
|
str/ft_strncmp.c \
|
||||||
ft_lstiter.c \
|
str/ft_strnstr.c \
|
||||||
ft_lstmap.c \
|
str/ft_strrchr.c \
|
||||||
|
str/ft_strtrim.c \
|
||||||
|
str/ft_substr.c \
|
||||||
|
str/ft_tolower.c \
|
||||||
|
str/ft_toupper.c \
|
||||||
|
|
||||||
OBJS = $(SRCS:.c=.o)
|
OBJS = $(SRCS:.c=.o)
|
||||||
|
|
||||||
OBJS_BONUS = $(SRCS_BONUS:.c=.o)
|
FLAGS = -Werror -Wall -Wextra -g
|
||||||
|
|
||||||
FLAGS = -Werror -Wall -Wextra
|
HEADERS = libft.h
|
||||||
|
|
||||||
HEADER = libft.h
|
LIB = print/printf/libftprintf.a
|
||||||
|
|
||||||
$(NAME): $(OBJS)
|
$(NAME): $(OBJS)
|
||||||
|
make -C io/get_next_line/
|
||||||
|
make -C print/printf/
|
||||||
ar -rcs $(NAME) $(OBJS)
|
ar -rcs $(NAME) $(OBJS)
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) $(FLAGS) -I $(HEADER) $< -c -o $@
|
$(CC) $(FLAGS) -I $(HEADERS) $< -c -o $@
|
||||||
|
|
||||||
all: $(NAME)
|
all: $(NAME)
|
||||||
|
|
||||||
bonus: $(OBJS_BONUS)
|
|
||||||
ar -rcs $(NAME) $(OBJS_BONUS)
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJS) $(OBJS_BONUS)
|
make -C io/get_next_line/ clean
|
||||||
|
make -C print/printf clean
|
||||||
|
rm -f $(OBJS)
|
||||||
|
|
||||||
fclean: clean
|
fclean: clean
|
||||||
|
make -C io/get_next_line/ fclean
|
||||||
|
make -C print/printf/ fclean
|
||||||
rm -f $(NAME)
|
rm -f $(NAME)
|
||||||
|
|
||||||
re: fclean all
|
re: fclean all
|
||||||
|
44
io/get_next_line/Makefile
Normal file
44
io/get_next_line/Makefile
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
# **************************************************************************** #
|
||||||
|
# #
|
||||||
|
# ::: :::::::: #
|
||||||
|
# Makefile :+: :+: :+: #
|
||||||
|
# +:+ +:+ +:+ #
|
||||||
|
# By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ #
|
||||||
|
# +#+#+#+#+#+ +#+ #
|
||||||
|
# Created: 2023/11/01 11:03:22 by adjoly #+# #+# #
|
||||||
|
# Updated: 2024/02/04 14:54:32 by adjoly ### ########.fr #
|
||||||
|
# #
|
||||||
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
NAME = get_next_line.a
|
||||||
|
|
||||||
|
CC = clang
|
||||||
|
|
||||||
|
SRCS = get_next_line.c \
|
||||||
|
get_next_line_utils.c \
|
||||||
|
../../mem/ft_calloc.c \
|
||||||
|
../../str/ft_strlen.c \
|
||||||
|
|
||||||
|
OBJS = $(SRCS:.c=.o)
|
||||||
|
|
||||||
|
FLAGS = -Werror -Wall -Wextra
|
||||||
|
|
||||||
|
HEADER = get_next_line.h
|
||||||
|
|
||||||
|
$(NAME): $(OBJS)
|
||||||
|
ar -rcs $(NAME) $(OBJS)
|
||||||
|
|
||||||
|
%.o: %.c
|
||||||
|
$(CC) $(FLAGS) -I $(HEADER) $< -c -o $@
|
||||||
|
|
||||||
|
all: $(NAME)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(OBJS)
|
||||||
|
|
||||||
|
fclean: clean
|
||||||
|
rm -f $(NAME)
|
||||||
|
|
||||||
|
re: fclean all
|
||||||
|
|
||||||
|
.PHONY: clean all re fclean
|
74
io/get_next_line/get_next_line.c
Normal file
74
io/get_next_line/get_next_line.c
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* get_next_line.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2023/12/01 17:11:59 by adjoly #+# #+# */
|
||||||
|
/* Updated: 2024/02/04 14:23:07 by adjoly ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "get_next_line.h"
|
||||||
|
|
||||||
|
char check_line(char *res, char *buf)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int j;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
j = 0;
|
||||||
|
while (res[i] && res[i] != '\n')
|
||||||
|
i++;
|
||||||
|
if (res[i] == '\n')
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
while (res[i])
|
||||||
|
{
|
||||||
|
buf[j] = res[i];
|
||||||
|
i++;
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
buf[j] = 0;
|
||||||
|
res[i - j] = 0;
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *ft_read_error(char **buf, char *res)
|
||||||
|
{
|
||||||
|
free(*buf);
|
||||||
|
*buf = NULL;
|
||||||
|
if (res[0] != 0)
|
||||||
|
return (res);
|
||||||
|
free(res);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *get_next_line(int fd)
|
||||||
|
{
|
||||||
|
static char *buf;
|
||||||
|
char *res;
|
||||||
|
ssize_t bytes_read;
|
||||||
|
|
||||||
|
if (BUFFER_SIZE <= 0 || fd < 0 || fd > 1023)
|
||||||
|
return (NULL);
|
||||||
|
if (!buf)
|
||||||
|
buf = ft_calloc(sizeof(char), BUFFER_SIZE + 1);
|
||||||
|
res = ft_calloc(1, 1);
|
||||||
|
while (buf)
|
||||||
|
{
|
||||||
|
res = ft_strjoin_gnl(res, buf);
|
||||||
|
if (!res)
|
||||||
|
return (NULL);
|
||||||
|
if (check_line(res, buf))
|
||||||
|
return (res);
|
||||||
|
bytes_read = read(fd, buf, BUFFER_SIZE);
|
||||||
|
if (bytes_read < 1)
|
||||||
|
return (ft_read_error(&buf, res));
|
||||||
|
buf[bytes_read] = 0;
|
||||||
|
}
|
||||||
|
return (NULL);
|
||||||
|
}
|
28
io/get_next_line/get_next_line.h
Normal file
28
io/get_next_line/get_next_line.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* get_next_line.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2023/12/01 17:12:00 by adjoly #+# #+# */
|
||||||
|
/* Updated: 2024/02/04 14:26:01 by adjoly ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef GET_NEXT_LINE_H
|
||||||
|
# define GET_NEXT_LINE_H
|
||||||
|
|
||||||
|
# include <unistd.h>
|
||||||
|
# include <stdlib.h>
|
||||||
|
|
||||||
|
# ifndef BUFFER_SIZE
|
||||||
|
# define BUFFER_SIZE 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
char *get_next_line(int fd);
|
||||||
|
char *ft_strjoin_gnl(char *s1, char *s2);
|
||||||
|
void *ft_calloc(size_t nmemb, size_t size);
|
||||||
|
size_t ft_strlen(char *s);
|
||||||
|
|
||||||
|
#endif
|
44
io/get_next_line/get_next_line_utils.c
Normal file
44
io/get_next_line/get_next_line_utils.c
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* get_next_line_utils.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2023/12/01 17:12:02 by adjoly #+# #+# */
|
||||||
|
/* Updated: 2024/02/04 14:24:58 by adjoly ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "get_next_line.h"
|
||||||
|
|
||||||
|
char *ft_strjoin_gnl(char *s1, char *s2)
|
||||||
|
{
|
||||||
|
char *result;
|
||||||
|
size_t i;
|
||||||
|
size_t j;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
j = 0;
|
||||||
|
if (!s2)
|
||||||
|
return (NULL);
|
||||||
|
result = ft_calloc((ft_strlen(s1) + ft_strlen(s2) + 1), sizeof(char));
|
||||||
|
if (result == NULL)
|
||||||
|
return (NULL);
|
||||||
|
while (s1[i])
|
||||||
|
{
|
||||||
|
result[i] = s1[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
while (s2[j])
|
||||||
|
{
|
||||||
|
result[i] = s2[j];
|
||||||
|
i++;
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
free(s1);
|
||||||
|
result[i] = '\0';
|
||||||
|
return (result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
BIN
io/get_next_line/objget_next_line.o
Normal file
BIN
io/get_next_line/objget_next_line.o
Normal file
Binary file not shown.
BIN
io/get_next_line/objget_next_line_utils.o
Normal file
BIN
io/get_next_line/objget_next_line_utils.o
Normal file
Binary file not shown.
BIN
libft.h.gch
BIN
libft.h.gch
Binary file not shown.
@ -3,20 +3,20 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_lstadd_back.c :+: :+: :+: */
|
/* ft_lstadd_back.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/11 16:37:42 by adjoly #+# #+# */
|
/* Created: 2023/11/11 16:37:42 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/11 17:56:48 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:56:37 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
void ft_lstadd_back(t_list **lst, t_list *new)
|
void ft_lstadd_back(t_list **lst, t_list *new)
|
||||||
{
|
{
|
||||||
if (lst == NULL)
|
if (!lst)
|
||||||
return ;
|
return ;
|
||||||
if (*lst == NULL)
|
if (!*lst)
|
||||||
{
|
{
|
||||||
(*lst) = new;
|
(*lst) = new;
|
||||||
return ;
|
return ;
|
@ -3,20 +3,20 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_lstadd_front.c :+: :+: :+: */
|
/* ft_lstadd_front.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/11 15:39:25 by adjoly #+# #+# */
|
/* Created: 2023/11/11 15:39:25 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/11 15:50:06 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:57:01 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
void ft_lstadd_front(t_list **lst, t_list *new)
|
void ft_lstadd_front(t_list **lst, t_list *new)
|
||||||
{
|
{
|
||||||
if (lst == NULL)
|
if (!lst)
|
||||||
return ;
|
return ;
|
||||||
if (new == NULL)
|
if (!new)
|
||||||
return ;
|
return ;
|
||||||
new->next = *lst;
|
new->next = *lst;
|
||||||
*lst = new;
|
*lst = new;
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_lstclear.c :+: :+: :+: */
|
/* ft_lstclear.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/11 18:05:14 by adjoly #+# #+# */
|
/* Created: 2023/11/11 18:05:14 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/12 16:19:59 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 13:55:17 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
void ft_lstclear(t_list **lst, void (*del)(void *))
|
void ft_lstclear(t_list **lst, void (*del)(void *))
|
||||||
{
|
{
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_lstdelone.c :+: :+: :+: */
|
/* ft_lstdelone.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/11 17:59:39 by adjoly #+# #+# */
|
/* Created: 2023/11/11 17:59:39 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/12 15:33:38 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 13:55:19 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
void ft_lstdelone(t_list *lst, void (*del)(void *))
|
void ft_lstdelone(t_list *lst, void (*del)(void *))
|
||||||
{
|
{
|
@ -3,18 +3,18 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_lstiter.c :+: :+: :+: */
|
/* ft_lstiter.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/11 18:20:25 by adjoly #+# #+# */
|
/* Created: 2023/11/11 18:20:25 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/11 18:23:58 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:58:16 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
void ft_lstiter(t_list *lst, void (*f)(void *))
|
void ft_lstiter(t_list *lst, void (*f)(void *))
|
||||||
{
|
{
|
||||||
if (lst == NULL || f == NULL)
|
if (!lst || !f)
|
||||||
return ;
|
return ;
|
||||||
while (lst)
|
while (lst)
|
||||||
{
|
{
|
@ -3,18 +3,18 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_lstlast.c :+: :+: :+: */
|
/* ft_lstlast.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/11 16:03:12 by adjoly #+# #+# */
|
/* Created: 2023/11/11 16:03:12 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/11 16:37:10 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:57:50 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
t_list *ft_lstlast(t_list *lst)
|
t_list *ft_lstlast(t_list *lst)
|
||||||
{
|
{
|
||||||
if (lst == NULL)
|
if (!lst)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
while (lst->next)
|
while (lst->next)
|
||||||
lst = lst->next;
|
lst = lst->next;
|
@ -3,21 +3,21 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_lstmap.c :+: :+: :+: */
|
/* ft_lstmap.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/11 18:24:49 by adjoly #+# #+# */
|
/* Created: 2023/11/11 18:24:49 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/11 18:38:51 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:58:45 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *))
|
t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *))
|
||||||
{
|
{
|
||||||
t_list *res;
|
t_list *res;
|
||||||
t_list *tmp;
|
t_list *tmp;
|
||||||
|
|
||||||
if (lst == NULL || f == NULL || del == NULL)
|
if (!lst || !f || !del)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
res = NULL;
|
res = NULL;
|
||||||
while (lst)
|
while (lst)
|
@ -3,21 +3,21 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_lstnew.c :+: :+: :+: */
|
/* ft_lstnew.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/11 15:30:32 by adjoly #+# #+# */
|
/* Created: 2023/11/11 15:30:32 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/11 15:51:49 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:58:59 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
t_list *ft_lstnew(void *content)
|
t_list *ft_lstnew(void *content)
|
||||||
{
|
{
|
||||||
t_list *lst;
|
t_list *lst;
|
||||||
|
|
||||||
lst = malloc(sizeof(t_list));
|
lst = malloc(sizeof(t_list));
|
||||||
if (lst == NULL)
|
if (!lst)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
lst[0].content = content;
|
lst[0].content = content;
|
||||||
lst[0].next = NULL;
|
lst[0].next = NULL;
|
@ -3,21 +3,21 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_lstsize.c :+: :+: :+: */
|
/* ft_lstsize.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/11 15:53:01 by adjoly #+# #+# */
|
/* Created: 2023/11/11 15:53:01 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/11 15:59:03 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:59:13 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
int ft_lstsize(t_list *lst)
|
int ft_lstsize(t_list *lst)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (lst != NULL)
|
while (lst)
|
||||||
{
|
{
|
||||||
lst = lst->next;
|
lst = lst->next;
|
||||||
i++;
|
i++;
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_bzero.c :+: :+: :+: */
|
/* ft_bzero.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/03 11:58:03 by adjoly #+# #+# */
|
/* Created: 2023/11/03 11:58:03 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/03 12:03:51 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 13:55:51 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
void ft_bzero(void *s, size_t n)
|
void ft_bzero(void *s, size_t n)
|
||||||
{
|
{
|
@ -3,27 +3,34 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_calloc.c :+: :+: :+: */
|
/* ft_calloc.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/01 16:02:26 by adjoly #+# #+# */
|
/* Created: 2023/11/01 16:02:26 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/11 01:32:30 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:22:20 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
#include <complex.h>
|
|
||||||
|
|
||||||
void *ft_calloc(size_t nmemb, size_t size)
|
void *ft_calloc(size_t nmemb, size_t size)
|
||||||
{
|
{
|
||||||
void *result;
|
char *result;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
if (size != 0 && nmemb != 0 && (nmemb * size) / nmemb != size)
|
i = 0;
|
||||||
return (NULL);
|
|
||||||
if (nmemb == 0 || size == 0)
|
if (nmemb == 0 || size == 0)
|
||||||
return (malloc(1));
|
return (malloc(1));
|
||||||
result = malloc(size * nmemb);
|
if (((unsigned long long)(size * nmemb) > 4294967295))
|
||||||
if (result == NULL)
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
ft_bzero(result, size * nmemb);
|
if ((int)size < 0 && (int)nmemb < 0)
|
||||||
|
return (NULL);
|
||||||
|
result = malloc(size * nmemb);
|
||||||
|
if (!result)
|
||||||
|
return (NULL);
|
||||||
|
while (i < (size * nmemb))
|
||||||
|
{
|
||||||
|
*(unsigned char *)(result + i) = '\0';
|
||||||
|
i++;
|
||||||
|
}
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_memchr.c :+: :+: :+: */
|
/* ft_memchr.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/05 14:52:53 by adjoly #+# #+# */
|
/* Created: 2023/11/05 14:52:53 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/09 14:27:32 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:36:28 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
void *ft_memchr(const void *s, int c, size_t n)
|
void *ft_memchr(const void *s, int c, size_t n)
|
||||||
{
|
{
|
@ -3,15 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_memcmp.c :+: :+: :+: */
|
/* ft_memcmp.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/08 12:04:48 by adjoly #+# #+# */
|
/* Created: 2023/11/08 12:04:48 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/09 14:06:17 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:36:46 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
int ft_memcmp(const void *s1, const void *s2, size_t n)
|
int ft_memcmp(const void *s1, const void *s2, size_t n)
|
||||||
{
|
{
|
@ -3,21 +3,21 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_memcpy.c :+: :+: :+: */
|
/* ft_memcpy.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/02 10:21:55 by adjoly #+# #+# */
|
/* Created: 2023/11/02 10:21:55 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/04 14:13:12 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 15:00:19 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
void *ft_memcpy(void *dest, const void *src, size_t n)
|
void *ft_memcpy(void *dest, const void *src, size_t n)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
if (src == NULL && dest == NULL)
|
if (!src && !dest)
|
||||||
{
|
{
|
||||||
return (dest);
|
return (dest);
|
||||||
}
|
}
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_memmove.c :+: :+: :+: */
|
/* ft_memmove.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/03 15:04:04 by adjoly #+# #+# */
|
/* Created: 2023/11/03 15:04:04 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/05 22:05:37 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:38:10 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
void *ft_memmove(void *dest, const void *src, size_t n)
|
void *ft_memmove(void *dest, const void *src, size_t n)
|
||||||
{
|
{
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_memset.c :+: :+: :+: */
|
/* ft_memset.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/10/31 17:40:22 by adjoly #+# #+# */
|
/* Created: 2023/10/31 17:40:22 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/03 12:11:08 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:37:55 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
void *ft_memset(void *s, int c, size_t n)
|
void *ft_memset(void *s, int c, size_t n)
|
||||||
{
|
{
|
18
print/ft_putchar.c
Normal file
18
print/ft_putchar.c
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_putchar.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2023/11/18 10:49:00 by adjoly #+# #+# */
|
||||||
|
/* Updated: 2024/02/04 15:00:50 by adjoly ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "../libft.h"
|
||||||
|
|
||||||
|
void ft_putchar(char c)
|
||||||
|
{
|
||||||
|
write(1, &c, 1);
|
||||||
|
}
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_putchar_fd.c :+: :+: :+: */
|
/* ft_putchar_fd.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/10/31 11:42:17 by adjoly #+# #+# */
|
/* Created: 2023/10/31 11:42:17 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/01 17:15:09 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:39:21 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
void ft_putchar_fd(char c, int fd)
|
void ft_putchar_fd(char c, int fd)
|
||||||
{
|
{
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_putendl_fd.c :+: :+: :+: */
|
/* ft_putendl_fd.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/09 19:12:00 by adjoly #+# #+# */
|
/* Created: 2023/11/09 19:12:00 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/09 19:15:50 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:40:09 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
void ft_putendl_fd(char *s, int fd)
|
void ft_putendl_fd(char *s, int fd)
|
||||||
{
|
{
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_putnbr.c :+: :+: :+: */
|
/* ft_putnbr.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/18 11:14:22 by adjoly #+# #+# */
|
/* Created: 2023/11/18 11:14:22 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/18 11:35:19 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:41:11 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
void ft_putnbr(int n)
|
void ft_putnbr(int n)
|
||||||
{
|
{
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_putnbr_fd.c :+: :+: :+: */
|
/* ft_putnbr_fd.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/10/31 11:52:46 by adjoly #+# #+# */
|
/* Created: 2023/10/31 11:52:46 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/03 19:17:27 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:42:15 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
void ft_putnbr_fd(int n, int fd)
|
void ft_putnbr_fd(int n, int fd)
|
||||||
{
|
{
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_putnbrbase.c :+: :+: :+: */
|
/* ft_putnbrbase.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/18 11:13:15 by adjoly #+# #+# */
|
/* Created: 2023/11/18 11:13:15 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/18 11:14:01 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 15:01:31 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
void ft_putnbrbase(int n, char *base)
|
void ft_putnbrbase(int n, char *base)
|
||||||
{
|
{
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_putnbrbase_fd.c :+: :+: :+: */
|
/* ft_putnbrbase_fd.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/18 10:57:44 by adjoly #+# #+# */
|
/* Created: 2023/11/18 10:57:44 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/18 11:10:32 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:41:30 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
void ft_putnbrbase_fd(int n, char *base, int fd)
|
void ft_putnbrbase_fd(int n, char *base, int fd)
|
||||||
{
|
{
|
@ -3,16 +3,17 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_putstr.c :+: :+: :+: */
|
/* ft_putstr.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/18 18:35:32 by adjoly #+# #+# */
|
/* Created: 2023/11/18 18:35:32 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/18 18:36:19 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 15:07:14 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
void ft_putstr(char *s)
|
void ft_putstr(char *s)
|
||||||
{
|
{
|
||||||
ft_putstr_fd(s, 1);
|
write(1, s, ft_strlen(s));
|
||||||
}
|
}
|
||||||
|
|
@ -3,25 +3,16 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_putstr_fd.c :+: :+: :+: */
|
/* ft_putstr_fd.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/10/31 11:45:55 by adjoly #+# #+# */
|
/* Created: 2023/10/31 11:45:55 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/05 15:06:13 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 15:08:44 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
void ft_putstr_fd(char *s, int fd)
|
void ft_putstr_fd(char *s, int fd)
|
||||||
{
|
{
|
||||||
int i;
|
write(fd, s, ft_strlen(s));
|
||||||
|
|
||||||
i = 0;
|
|
||||||
if (s == NULL)
|
|
||||||
return ;
|
|
||||||
while (s[i])
|
|
||||||
{
|
|
||||||
write(fd, &s[i], 1);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
}
|
46
print/printf/Makefile
Normal file
46
print/printf/Makefile
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# **************************************************************************** #
|
||||||
|
# #
|
||||||
|
# ::: :::::::: #
|
||||||
|
# Makefile :+: :+: :+: #
|
||||||
|
# +:+ +:+ +:+ #
|
||||||
|
# By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ #
|
||||||
|
# +#+#+#+#+#+ +#+ #
|
||||||
|
# Created: 2023/11/17 12:35:27 by adjoly #+# #+# #
|
||||||
|
# Updated: 2023/11/20 15:55:52 by adjoly ### ########.fr #
|
||||||
|
# #
|
||||||
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
NAME = libftprintf.a
|
||||||
|
|
||||||
|
CC = cc
|
||||||
|
|
||||||
|
SRCS = ft_printf.c \
|
||||||
|
ft_putchar.c \
|
||||||
|
ft_putnbr.c \
|
||||||
|
ft_putnbrbase.c \
|
||||||
|
ft_putstr.c \
|
||||||
|
ft_strlen.c \
|
||||||
|
|
||||||
|
OBJS = $(SRCS:.c=.o)
|
||||||
|
|
||||||
|
FLAGS = -Werror -Wall -Wextra
|
||||||
|
|
||||||
|
HEADER = libftprintf.h
|
||||||
|
|
||||||
|
$(NAME): $(OBJS)
|
||||||
|
ar -rcs $(NAME) $(OBJS)
|
||||||
|
|
||||||
|
%.o: %.c
|
||||||
|
$(CC) $(FLAGS) -I $(HEADER) $< -c -o $@
|
||||||
|
|
||||||
|
all: $(NAME)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(OBJS)
|
||||||
|
|
||||||
|
fclean: clean
|
||||||
|
rm -f $(NAME)
|
||||||
|
|
||||||
|
re: fclean all
|
||||||
|
|
||||||
|
.PHONY: clean all re fclean
|
92
print/printf/ft_printf.c
Normal file
92
print/printf/ft_printf.c
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_printf.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2023/11/17 16:48:37 by adjoly #+# #+# */
|
||||||
|
/* Updated: 2023/12/06 14:27:05 by adjoly ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "ft_printf.h"
|
||||||
|
|
||||||
|
int ft_putaddr(void *ptr)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
|
||||||
|
if (ptr == NULL)
|
||||||
|
return (write(1, "(nil)", 5));
|
||||||
|
write(1, "0x", 2);
|
||||||
|
r = ft_putnbrbase_p((long unsigned int)ptr, "0123456789abcdef");
|
||||||
|
return (2 + r);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ft_putnbrulong(unsigned int n)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
|
||||||
|
len = 0;
|
||||||
|
if (n < 10)
|
||||||
|
len += write(1, &(char){n + '0'}, 1);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
len += ft_putnbrulong(n / 10);
|
||||||
|
len += write(1, &(char){n % 10 + '0'}, 1);
|
||||||
|
}
|
||||||
|
return (len);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ft_printconversion(char conversion, va_list args)
|
||||||
|
{
|
||||||
|
int count;
|
||||||
|
|
||||||
|
count = 0;
|
||||||
|
if (conversion == '%')
|
||||||
|
count = ft_putchar('%');
|
||||||
|
else if (conversion == 's')
|
||||||
|
count = ft_putstr(va_arg(args, char *));
|
||||||
|
else if (conversion == 'c')
|
||||||
|
count = ft_putchar(va_arg(args, int));
|
||||||
|
else if (conversion == 'i' || conversion == 'd')
|
||||||
|
count = ft_putnbr(va_arg(args, int));
|
||||||
|
else if (conversion == 'u')
|
||||||
|
count = ft_putnbrulong(va_arg(args, unsigned int));
|
||||||
|
else if (conversion == 'p')
|
||||||
|
count = ft_putaddr(va_arg(args, void *));
|
||||||
|
else if (conversion == 'x')
|
||||||
|
count = ft_putnbrbase(va_arg(args, unsigned long), "0123456789abcdef");
|
||||||
|
else if (conversion == 'X')
|
||||||
|
count = ft_putnbrbase(va_arg(args, unsigned long), "0123456789ABCDEF");
|
||||||
|
return (count);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ft_printf(const char *format, ...)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
va_list args;
|
||||||
|
int count;
|
||||||
|
|
||||||
|
va_start(args, format);
|
||||||
|
count = 0;
|
||||||
|
i = 0;
|
||||||
|
if (format == NULL)
|
||||||
|
return (-1);
|
||||||
|
while (format[i])
|
||||||
|
{
|
||||||
|
if (format[i] == '%')
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
if (format[i])
|
||||||
|
count += ft_printconversion(format[i], args);
|
||||||
|
else
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
count += ft_putchar(format[i]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
va_end(args);
|
||||||
|
return (count);
|
||||||
|
}
|
33
print/printf/ft_printf.h
Normal file
33
print/printf/ft_printf.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_printf.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2023/11/17 16:50:36 by adjoly #+# #+# */
|
||||||
|
/* Updated: 2023/11/22 14:00:38 by adjoly ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef FT_PRINTF_H
|
||||||
|
# define FT_PRINTF_H
|
||||||
|
|
||||||
|
# include <stdlib.h>
|
||||||
|
# include <stdarg.h>
|
||||||
|
# include <unistd.h>
|
||||||
|
|
||||||
|
int ft_printf(const char *format, ...);
|
||||||
|
int ft_printconversion(char conversion, va_list args);
|
||||||
|
int ft_putnbrulong(unsigned int n);
|
||||||
|
int ft_putaddr(void *ptr);
|
||||||
|
|
||||||
|
int ft_putstr(char *s);
|
||||||
|
|
||||||
|
int ft_putnbrbase_p(unsigned long int n, char *base);
|
||||||
|
int ft_putnbrbase(unsigned int n, char *base);
|
||||||
|
int ft_putchar(char c);
|
||||||
|
int ft_putnbr(int n);
|
||||||
|
size_t ft_strlen(const char *s);
|
||||||
|
|
||||||
|
#endif
|
@ -6,13 +6,14 @@
|
|||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/18 10:49:00 by adjoly #+# #+# */
|
/* Created: 2023/11/18 10:49:00 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/18 10:50:35 by adjoly ### ########.fr */
|
/* Updated: 2023/11/22 11:07:22 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "ft_printf.h"
|
||||||
|
|
||||||
void ft_putchar(char c)
|
int ft_putchar(char c)
|
||||||
{
|
{
|
||||||
ft_putchar_fd(c, 1);
|
write(1, &c, 1);
|
||||||
|
return (1);
|
||||||
}
|
}
|
36
print/printf/ft_putnbr.c
Normal file
36
print/printf/ft_putnbr.c
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_putnbr.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2023/10/31 11:52:46 by adjoly #+# #+# */
|
||||||
|
/* Updated: 2023/11/22 10:51:24 by adjoly ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "ft_printf.h"
|
||||||
|
|
||||||
|
int ft_putnbr(int n)
|
||||||
|
{
|
||||||
|
unsigned int nbr;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
len = 0;
|
||||||
|
if (n < 0)
|
||||||
|
{
|
||||||
|
len += write(1, "-", 1);
|
||||||
|
nbr = -n;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
nbr = n;
|
||||||
|
if (nbr < 10)
|
||||||
|
len += write(1, &(char){nbr + '0'}, 1);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
len += ft_putnbr(nbr / 10);
|
||||||
|
len += write(1, &(char){nbr % 10 + '0'}, 1);
|
||||||
|
}
|
||||||
|
return (len);
|
||||||
|
}
|
47
print/printf/ft_putnbrbase.c
Normal file
47
print/printf/ft_putnbrbase.c
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_putnbrbase.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2023/11/18 10:57:44 by adjoly #+# #+# */
|
||||||
|
/* Updated: 2023/11/22 14:02:37 by adjoly ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "ft_printf.h"
|
||||||
|
|
||||||
|
int ft_putnbrbase(unsigned int n, char *base)
|
||||||
|
{
|
||||||
|
unsigned int base_len;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
len = 0;
|
||||||
|
base_len = (int)ft_strlen(base);
|
||||||
|
if (n < base_len)
|
||||||
|
len += write(1, &base[n % base_len], 1);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
len += ft_putnbrbase(n / base_len, base);
|
||||||
|
len += write(1, &base[n % base_len], 1);
|
||||||
|
}
|
||||||
|
return (len);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ft_putnbrbase_p(unsigned long int n, char *base)
|
||||||
|
{
|
||||||
|
unsigned long int base_len;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
len = 0;
|
||||||
|
base_len = (int)ft_strlen(base);
|
||||||
|
if (n < base_len)
|
||||||
|
len += write(1, &base[n % base_len], 1);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
len += ft_putnbrbase_p(n / base_len, base);
|
||||||
|
len += write(1, &base[n % base_len], 1);
|
||||||
|
}
|
||||||
|
return (len);
|
||||||
|
}
|
31
print/printf/ft_putstr.c
Normal file
31
print/printf/ft_putstr.c
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_putstr.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2023/10/31 11:45:55 by adjoly #+# #+# */
|
||||||
|
/* Updated: 2023/11/20 15:51:38 by adjoly ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "ft_printf.h"
|
||||||
|
|
||||||
|
int ft_putstr(char *s)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
if (s == NULL)
|
||||||
|
{
|
||||||
|
write(1, "(null)", 6);
|
||||||
|
return (6);
|
||||||
|
}
|
||||||
|
while (s[i])
|
||||||
|
{
|
||||||
|
write(1, &s[i], 1);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (i);
|
||||||
|
}
|
@ -6,11 +6,11 @@
|
|||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/10/30 18:15:57 by adjoly #+# #+# */
|
/* Created: 2023/10/30 18:15:57 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/01 17:15:12 by adjoly ### ########.fr */
|
/* Updated: 2023/11/20 15:51:51 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "ft_printf.h"
|
||||||
|
|
||||||
size_t ft_strlen(const char *s)
|
size_t ft_strlen(const char *s)
|
||||||
{
|
{
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_itoa.c :+: :+: :+: */
|
/* ft_itoa.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/05 16:26:26 by adjoly #+# #+# */
|
/* Created: 2023/11/05 16:26:26 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/06 15:36:28 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:45:39 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
static int ft_count_digit(int n)
|
static int ft_count_digit(int n)
|
||||||
{
|
{
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_split.c :+: :+: :+: */
|
/* ft_split.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/12 09:14:19 by adjoly #+# #+# */
|
/* Created: 2023/11/12 09:14:19 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/12 16:28:35 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:43:50 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
static int ft_countword(char const *s, char sep)
|
static int ft_countword(char const *s, char sep)
|
||||||
{
|
{
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_strchr.c :+: :+: :+: */
|
/* ft_strchr.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/01 15:45:18 by adjoly #+# #+# */
|
/* Created: 2023/11/01 15:45:18 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/09 14:31:55 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:44:11 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
char *ft_strchr(const char *s, int c)
|
char *ft_strchr(const char *s, int c)
|
||||||
{
|
{
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_strdup.c :+: :+: :+: */
|
/* ft_strdup.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/03 22:57:39 by adjoly #+# #+# */
|
/* Created: 2023/11/03 22:57:39 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/04 14:40:17 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:44:58 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
char *ft_strdup(const char *s)
|
char *ft_strdup(const char *s)
|
||||||
{
|
{
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_striteri.c :+: :+: :+: */
|
/* ft_striteri.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/11 14:15:30 by adjoly #+# #+# */
|
/* Created: 2023/11/11 14:15:30 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/12 13:59:23 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:45:11 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
void ft_striteri(char *s, void (*f)(unsigned int, char *))
|
void ft_striteri(char *s, void (*f)(unsigned int, char *))
|
||||||
{
|
{
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_strjoin.c :+: :+: :+: */
|
/* ft_strjoin.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/04 13:44:09 by adjoly #+# #+# */
|
/* Created: 2023/11/04 13:44:09 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/12 16:18:45 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:45:30 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
char *ft_strjoin(char const *s1, char const *s2)
|
char *ft_strjoin(char const *s1, char const *s2)
|
||||||
{
|
{
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_strlcat.c :+: :+: :+: */
|
/* ft_strlcat.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/03 15:59:31 by adjoly #+# #+# */
|
/* Created: 2023/11/03 15:59:31 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/05 10:39:34 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:47:03 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
size_t ft_strlcat(char *dst, const char *src, size_t size)
|
size_t ft_strlcat(char *dst, const char *src, size_t size)
|
||||||
{
|
{
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_strlcpy.c :+: :+: :+: */
|
/* ft_strlcpy.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/01 09:52:45 by adjoly #+# #+# */
|
/* Created: 2023/11/01 09:52:45 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/03 22:46:49 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:47:41 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
size_t ft_strlcpy(char *dst, const char *src, size_t size)
|
size_t ft_strlcpy(char *dst, const char *src, size_t size)
|
||||||
{
|
{
|
26
str/ft_strlen.c
Normal file
26
str/ft_strlen.c
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_strlen.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2023/10/30 18:15:57 by adjoly #+# #+# */
|
||||||
|
/* Updated: 2024/02/04 15:10:15 by adjoly ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "../libft.h"
|
||||||
|
|
||||||
|
size_t ft_strlen(const char *s)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (*s)
|
||||||
|
{
|
||||||
|
s++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (i);
|
||||||
|
}
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_strmapi.c :+: :+: :+: */
|
/* ft_strmapi.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/11 11:44:24 by adjoly #+# #+# */
|
/* Created: 2023/11/11 11:44:24 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/13 16:14:32 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:48:02 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
|
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
|
||||||
{
|
{
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_strncmp.c :+: :+: :+: */
|
/* ft_strncmp.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/05 10:40:45 by adjoly #+# #+# */
|
/* Created: 2023/11/05 10:40:45 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/06 14:53:38 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:48:12 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
int ft_strncmp(const char *s1, const char *s2, size_t n)
|
int ft_strncmp(const char *s1, const char *s2, size_t n)
|
||||||
{
|
{
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_strnstr.c :+: :+: :+: */
|
/* ft_strnstr.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/08 16:02:17 by adjoly #+# #+# */
|
/* Created: 2023/11/08 16:02:17 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/12 16:17:28 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:48:22 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
char *ft_strnstr(const char *big, const char *little, size_t len)
|
char *ft_strnstr(const char *big, const char *little, size_t len)
|
||||||
{
|
{
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_strrchr.c :+: :+: :+: */
|
/* ft_strrchr.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/08 14:44:26 by adjoly #+# #+# */
|
/* Created: 2023/11/08 14:44:26 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/08 15:21:28 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:48:34 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
char *ft_strrchr(const char *s, int c)
|
char *ft_strrchr(const char *s, int c)
|
||||||
{
|
{
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_strtrim.c :+: :+: :+: */
|
/* ft_strtrim.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/11 00:37:37 by adjoly #+# #+# */
|
/* Created: 2023/11/11 00:37:37 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/11 01:09:36 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:48:45 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
char *ft_strtrim(char const *s1, char const *set)
|
char *ft_strtrim(char const *s1, char const *set)
|
||||||
{
|
{
|
@ -3,14 +3,14 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_substr.c :+: :+: :+: */
|
/* ft_substr.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/11/02 17:59:58 by adjoly #+# #+# */
|
/* Created: 2023/11/02 17:59:58 by adjoly #+# #+# */
|
||||||
/* Updated: 2023/11/13 16:22:26 by adjoly ### ########.fr */
|
/* Updated: 2024/02/04 14:48:54 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "../libft.h"
|
||||||
|
|
||||||
char *ft_substr(char const *s, unsigned int start, size_t len)
|
char *ft_substr(char const *s, unsigned int start, size_t len)
|
||||||
{
|
{
|
Reference in New Issue
Block a user