add: extra function
This commit is contained in:
parent
3ad6814405
commit
88d69ebcea
@ -6,13 +6,13 @@
|
|||||||
# By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ #
|
# By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2022/09/27 08:39:27 by cchauvet #+# #+# #
|
# Created: 2022/09/27 08:39:27 by cchauvet #+# #+# #
|
||||||
# Updated: 2023/04/26 12:14:25 by cchauvet ### ########.fr #
|
# Updated: 2023/05/03 11:01:55 by cchauvet ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
CC = clang
|
CC = clang
|
||||||
|
|
||||||
SRCS = ft_contain_only.c ft_freer.c ft_is_in.c ft_random_generator.c ft_strchri.c ft_strcmp.c ft_strfjoin.c ft_strgen.c ft_strmerger.c ft_strndup.c ft_tabrealloc.c ft_ultoa_base.c ft_swap.c ft_tablen.c
|
SRCS = ft_contain_only.c ft_freer.c ft_is_in.c ft_random_generator.c ft_strchri.c ft_strcmp.c ft_strfjoin.c ft_strgen.c ft_strmerger.c ft_strndup.c ft_tabrealloc.c ft_ultoa_base.c ft_swap.c ft_tablen.c ft_atoul.c ft_atoul_check.c
|
||||||
|
|
||||||
OBJS = $(SRCS:.c=.o)
|
OBJS = $(SRCS:.c=.o)
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/01/04 14:03:10 by cchauvet #+# #+# */
|
/* Created: 2023/01/04 14:03:10 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/04/26 12:24:00 by cchauvet ### ########.fr */
|
/* Updated: 2023/05/03 11:02:33 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -14,11 +14,14 @@
|
|||||||
# define EXTRA_H
|
# define EXTRA_H
|
||||||
# include <stdarg.h>
|
# include <stdarg.h>
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
|
#include <sys/types.h>
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
# include <fcntl.h>
|
# include <fcntl.h>
|
||||||
# include "../libft/libft.h"
|
# include "../libft/libft.h"
|
||||||
|
|
||||||
size_t ft_tablen(const char **tab);
|
unsigned long ft_atoul(const char str[]);
|
||||||
|
int ft_atoul_check(const char str[]);
|
||||||
|
size_t ft_tablen(const void **tab);
|
||||||
char *ft_ultoa_base(unsigned long long n, char *base);
|
char *ft_ultoa_base(unsigned long long n, char *base);
|
||||||
char *get_next_line(int fd);
|
char *get_next_line(int fd);
|
||||||
size_t ft_random_generator(size_t start, size_t stop);
|
size_t ft_random_generator(size_t start, size_t stop);
|
||||||
@ -27,12 +30,12 @@ void ft_freer_ultimate(size_t len, ...);
|
|||||||
char *ft_strgen(char c, size_t len);
|
char *ft_strgen(char c, size_t len);
|
||||||
char *ft_strfjoin(char *s1, char *s2);
|
char *ft_strfjoin(char *s1, char *s2);
|
||||||
char *ft_strmerger(size_t arg_len, ...);
|
char *ft_strmerger(size_t arg_len, ...);
|
||||||
int ft_is_in(char *str, char c);
|
int ft_is_in(const char *str, char c);
|
||||||
char **ft_tabrealloc(char **tab, size_t current_size, size_t new_size);
|
char **ft_tabrealloc(char **tab, size_t current_size, size_t new_size);
|
||||||
char *ft_strndup(const char *src, size_t n);
|
char *ft_strndup(const char *src, size_t n);
|
||||||
ssize_t ft_strchri(char *str, char c);
|
ssize_t ft_strchri(char *str, char c);
|
||||||
int ft_contain_only_str(char *str, char *to_find);
|
int ft_contain_only_str(const char *str, const char *to_find);
|
||||||
int ft_contain_only(char *str, char c);
|
int ft_contain_only(const char *str, char c);
|
||||||
int ft_strcmp(const char *s1, const char *s2);
|
int ft_strcmp(const char *s1, const char *s2);
|
||||||
void ft_swap(void *a, void *b);
|
void ft_swap(void *a, void *b);
|
||||||
void ft_swap_int(int *a, int *b);
|
void ft_swap_int(int *a, int *b);
|
||||||
|
38
libftx/extra/ft_atoul.c
Normal file
38
libftx/extra/ft_atoul.c
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_atoul.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2022/09/27 16:14:34 by cchauvet #+# #+# */
|
||||||
|
/* Updated: 2023/05/03 11:03:04 by cchauvet ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "extra.h"
|
||||||
|
|
||||||
|
unsigned long ft_atoul(const char *str)
|
||||||
|
{
|
||||||
|
unsigned long out;
|
||||||
|
char sign;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
sign = 1;
|
||||||
|
i = 0;
|
||||||
|
while (str[i] == '-' || str[i] == '+')
|
||||||
|
{
|
||||||
|
if (str[i] == '-')
|
||||||
|
sign = -1;
|
||||||
|
if (str[i] == '+')
|
||||||
|
sign = 1;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
out = 0;
|
||||||
|
while (str[i] >= '0' && str[i] <= '9')
|
||||||
|
{
|
||||||
|
out = out * 10 + str[i] - 48;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (out * sign);
|
||||||
|
}
|
32
libftx/extra/ft_atoul_check.c
Normal file
32
libftx/extra/ft_atoul_check.c
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_atoul_check.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2023/03/08 14:43:33 by cchauvet #+# #+# */
|
||||||
|
/* Updated: 2023/05/02 13:15:12 by cchauvet ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "./extra.h"
|
||||||
|
|
||||||
|
int ft_atoul_check(const char str[])
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
unsigned long num;
|
||||||
|
|
||||||
|
num = 0;
|
||||||
|
i = 0;
|
||||||
|
while (str[i] != '\0')
|
||||||
|
{
|
||||||
|
if (str[i] > '9' || str[i] < '0')
|
||||||
|
return (0);
|
||||||
|
if (num > num * 10 + str[i] - '0')
|
||||||
|
return (0);
|
||||||
|
num = num * 10 + str[i] - 48;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (1);
|
||||||
|
}
|
@ -6,13 +6,13 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/01/12 16:28:20 by cchauvet #+# #+# */
|
/* Created: 2023/01/12 16:28:20 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/01/12 16:31:22 by cchauvet ### ########.fr */
|
/* Updated: 2023/04/26 13:07:06 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "extra.h"
|
#include "extra.h"
|
||||||
|
|
||||||
int ft_contain_only(char *str, char c)
|
int ft_contain_only(const char *str, char c)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ int ft_contain_only(char *str, char c)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ft_contain_only_str(char *str, char *to_find)
|
int ft_contain_only_str(const char *str, const char *to_find)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/01/05 20:29:53 by cchauvet #+# #+# */
|
/* Created: 2023/01/05 20:29:53 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/01/08 12:15:08 by cchauvet ### ########.fr */
|
/* Updated: 2023/04/26 13:07:30 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "extra.h"
|
#include "extra.h"
|
||||||
|
|
||||||
int ft_is_in(char *str, char c)
|
int ft_is_in(const char *str, char c)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/04/26 12:12:19 by cchauvet #+# #+# */
|
/* Created: 2023/04/26 12:12:19 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/04/26 12:13:38 by cchauvet ### ########.fr */
|
/* Updated: 2023/04/28 12:58:24 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "./extra.h"
|
#include "./extra.h"
|
||||||
|
|
||||||
size_t ft_tablen(const char **tab)
|
size_t ft_tablen(const void **tab)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/09/26 14:47:54 by cchauvet #+# #+# */
|
/* Created: 2022/09/26 14:47:54 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/04/26 12:22:51 by cchauvet ### ########.fr */
|
/* Updated: 2023/05/02 13:17:30 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -16,8 +16,9 @@
|
|||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
# include <stdarg.h>
|
# include <stdarg.h>
|
||||||
# include "./libft/libft.h"
|
# include "./libft/libft.h"
|
||||||
|
# include "./extra/extra.h"
|
||||||
|
|
||||||
size_t ft_tablen(const char **tab);
|
size_t ft_tablen(const void **tab);
|
||||||
char *ft_ultoa_base(unsigned long long n, char *base);
|
char *ft_ultoa_base(unsigned long long n, char *base);
|
||||||
int ft_printf(const char *format, ...);
|
int ft_printf(const char *format, ...);
|
||||||
int ft_eprintf(const char *format, ...);
|
int ft_eprintf(const char *format, ...);
|
||||||
@ -28,10 +29,10 @@ size_t ft_random_generator(size_t start, size_t stop);
|
|||||||
void ft_freer_tab_ultimate(size_t len, ...);
|
void ft_freer_tab_ultimate(size_t len, ...);
|
||||||
void ft_freer_ultimate(size_t len, ...);
|
void ft_freer_ultimate(size_t len, ...);
|
||||||
char *ft_strgen(char c, size_t len);
|
char *ft_strgen(char c, size_t len);
|
||||||
int ft_is_in(char *str, char c);
|
int ft_is_in(const char *str, char c);
|
||||||
char **ft_tabrealloc(char **tab, size_t current_size, size_t new_size);
|
char **ft_tabrealloc(char **tab, size_t current_size, size_t new_size);
|
||||||
int ft_contain_only_str(char *str, char *to_find);
|
int ft_contain_only_str(const char *str, const char *to_find);
|
||||||
int ft_contain_only(char *str, char c);
|
int ft_contain_only(const char *str, char c);
|
||||||
char *ft_strfjoin(char *s1, char *s2);
|
char *ft_strfjoin(char *s1, char *s2);
|
||||||
char *ft_strmerger(size_t arg_len, ...);
|
char *ft_strmerger(size_t arg_len, ...);
|
||||||
int ft_strcmp(const char *s1, const char *s2);
|
int ft_strcmp(const char *s1, const char *s2);
|
||||||
@ -41,41 +42,4 @@ void ft_swap(void *a, void *b);
|
|||||||
void ft_swap_int(int *a, int *b);
|
void ft_swap_int(int *a, int *b);
|
||||||
void ft_swap_char(char *a, char *b);
|
void ft_swap_char(char *a, char *b);
|
||||||
|
|
||||||
/* void *ft_cancel(void **tab, size_t len); */
|
|
||||||
/* int ft_atoi(const char *nptr); */
|
|
||||||
/* void ft_bzero(void *s, size_t n); */
|
|
||||||
/* void *ft_calloc(size_t nmemb, size_t size); */
|
|
||||||
/* 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); */
|
|
||||||
/* void *ft_memchr(const void *s, int c, size_t n); */
|
|
||||||
/* int ft_memcmp(const void *s1, const void *s2, 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); */
|
|
||||||
/* char *ft_strchr(const char *s, int c); */
|
|
||||||
/* char *ft_strdup(const char *s); */
|
|
||||||
/* 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); */
|
|
||||||
/* int ft_strncmp(const char *s1, const char *s2, size_t n); */
|
|
||||||
/* char *ft_strnstr(const char *big, const char *little, size_t len); */
|
|
||||||
/* char *ft_strrchr(const char *s, int c); */
|
|
||||||
/* int ft_tolower(int c); */
|
|
||||||
/* int ft_toupper(int c); */
|
|
||||||
|
|
||||||
/* char *ft_substr(char const *s, unsigned int start, size_t len); */
|
|
||||||
/* char *ft_strjoin(char const *s1, char const *s2); */
|
|
||||||
/* char *ft_strtrim(char const *s1, char const *set); */
|
|
||||||
/* char **ft_split(char const *s, char c); */
|
|
||||||
/* char *ft_itoa(int n); */
|
|
||||||
/* char *ft_strmapi(char const *s, char (*f)(unsigned int, char)); */
|
|
||||||
/* void ft_striteri(char *s, void (*f)(unsigned int, char*)); */
|
|
||||||
/* void ft_putchar_fd(char c, int fd); */
|
|
||||||
/* void ft_putstr_fd(char *s, int fd); */
|
|
||||||
/* void ft_putendl_fd(char *s, int fd); */
|
|
||||||
/* void ft_putnbr_fd(int n, int fd); */
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user