This commit is contained in:
Camille Chauvet
2023-05-17 16:45:25 +00:00
commit 29ed24d567
619 changed files with 16119 additions and 0 deletions

49
Rush/Rush02/ex00/Makefile Normal file
View File

@ -0,0 +1,49 @@
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: kcarrere <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/07/30 15:25:55 by kcarrere #+# #+# #
# Updated: 2022/07/31 19:57:59 by kcarrere ### ########.fr #
# #
# **************************************************************************** #
NAME = rush-02
SRC = decompose.c \
dictionary_checker.c \
file_reader.c \
ft_atoapc.c \
ft_atoi.c \
ft_atonbr.c \
ft_ctoa.c \
ft_printapc.c \
ft_print_dicterror.c \
ft_print_error.c \
ft_putstr.c \
ft_reverse_str.c \
ft_split.c \
ft_strcat.c \
ft_strcmp.c \
ft_strlen.c \
ft_strstr.c \
ft_tablen.c \
ft_tabnbr.c \
main.c
FLAGS = -Wall -Werror -Wextra
all: ${NAME}
$(NAME):
gcc -o ${NAME} ${SRC} -Iincludes ${FLAGS}
clean:
rm -f *.o
fclean: clean
rm -f ${NAME}
.PHONY: all clean fclean

View File

@ -0,0 +1,95 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* decompose.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 21:30:41 by cchauvet #+# #+# */
/* Updated: 2022/07/31 23:38:02 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
char *ft_power_of_ten(unsigned int power)
{
char *nbr;
unsigned int i;
nbr = malloc(sizeof(*nbr) * (power + 2));
nbr[0] = '1';
i = 1;
while (i < power)
{
nbr[i] = '0';
i++;
}
nbr[i] = '\0';
return (nbr);
}
void ft_decompose_by_char(char **tab, int *i, int *c, char *nbr)
{
tab[*i] = malloc(sizeof(**tab) * 20);
if (nbr[*c] > '0')
{
if ((ft_strlen(nbr) - *c) % 3 == 0)
{
tab[(*i)++] = ctoa(nbr[*c], 2);
tab[*i] = malloc(sizeof(**tab) * 20);
tab[(*i)++] = "100";
}
else if ((ft_strlen(nbr) - *c) % 3 == 2)
{
if (nbr[*c] == '1')
{
if (nbr[*c + 1] > '0')
{
tab[(*i)++] = cat(ctoa(nbr[*c], 3), ctoa(nbr[*c + 1], 2));
*c = *c + 1;
}
}
else
tab[(*i)++] = cat(ctoa(nbr[*c], 3), "0");
}
else
tab[(*i)++] = ctoa(nbr[*c], 2);
}
}
void ft_last_value(char **str, int *i)
{
str[*i] = malloc(sizeof(**str));
str[*i] = "";
}
char **ft_decompose(char *nbr)
{
unsigned int packets;
int *i;
int *c;
char **tab;
i = malloc(sizeof(*i));
*i = 0;
c = malloc(sizeof(*i));
*c = 0;
tab = malloc(sizeof(*tab) * 20);
packets = ft_strlen(nbr) / 3 + ((ft_strlen(nbr) % 3) != 0);
while (nbr[*c] != '\0')
{
ft_decompose_by_char(tab, i, c, nbr);
if (packets > 1)
{
if ((ft_strlen(nbr) - *c) % 3 == 1)
{
tab[*i] = malloc(sizeof(**tab) * 20);
tab[*i] = ft_power_of_ten(ft_strlen(nbr) - *c);
}
}
*c += 1;
}
ft_last_value(tab, i);
return (tab);
}

View File

@ -0,0 +1,114 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* dictionary_checker.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 20:31:53 by cchauvet #+# #+# */
/* Updated: 2022/07/31 20:36:31 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
char *ft_doubleline(char *str)
{
int i;
int j;
char *tab;
i = 0;
j = 0;
tab = malloc(sizeof(*str) * ft_strlen(str + 1));
while (str[i] != '\0')
{
tab[j] = str[i];
i++;
j++;
if (str[i] == '\n' && str[i + 1] == '\n')
while (str[i + 1] == '\n' && str[i])
i++;
}
tab[i] = '\0';
return (tab);
}
t_number *ft_dictionnary_reader(char *path)
{
char *str;
char **lines;
int i;
t_number *tab;
str = ft_filereader(path);
str = ft_doubleline(str);
lines = ft_split(str, "\n");
tab = malloc((ft_lines_counter(lines) + 1) * sizeof(*tab));
i = -1;
while (++i < ft_lines_counter(lines))
{
tab[i].nbr = malloc(sizeof(*(tab[i].nbr)) * ft_strlen(ft_atonbr(lines[i])));
tab[i].apc = malloc(sizeof(*(tab[i].apc)) * ft_strlen(ft_atoapc(lines[i])));
if (ft_strlen(ft_atonbr(lines[i])) * ft_strlen(ft_atoapc(lines[i])) == 0)
tab[i].nbr = "";
else
{
if (ft_print_dicterror(lines[i]) == 0)
return (tab = NULL);
tab[i].nbr = ft_atonbr(lines[i]);
tab[i].apc = ft_atoapc(lines[i]);
}
}
tab[i].nbr = "";
tab[i].apc = "";
return (tab);
}
int ft_dict_is_valid(char *path)
{
t_number *my_dict;
t_number *other_dict;
int i;
int j;
my_dict = ft_dictionnary_reader(PATH);
other_dict = ft_dictionnary_reader(path);
if (my_dict == NULL || other_dict == NULL)
return (0);
i = 0;
while (my_dict[i].nbr[0] != '\0')
{
j = 0;
while (other_dict[j].nbr[0] != '\0')
{
if (ft_strcmp(my_dict[i].nbr, other_dict[i].nbr) == 0)
break;
j++;
}
if (ft_strcmp(my_dict[i].nbr, other_dict[i].nbr) != 0)
{
free(other_dict);
free(my_dict);
return (0);
}
i++;
}
free(other_dict);
free(my_dict);
return (1);
}
/*
int main()
{
int i;
char *path;
printf("%d", ft_dict_is_valide("./numbers_test.dict"));
path = "numbers_test.dict";
i = 0;
while (ft_dictionnary_reader(path)[++i].nbr[0] != '\0')
printf("%s : %s\n", ft_dictionnary_reader(path)[i].nbr, ft_dictionnary_reader(PATH)[i].apc);
}
*/

View File

@ -0,0 +1,63 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* file_reader.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nlauvray <nlauvray@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 08:54:40 by nlauvray #+# #+# */
/* Updated: 2022/07/31 09:19:33 by nlauvray ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
int ft_filelen(char *path)
{
int file_descriptor;
int letter_readed_counter;
char letters_readed[10];
int length;
file_descriptor = open(path, O_RDONLY);
if (file_descriptor == -1)
return (-1);
length = 0;
letter_readed_counter = -1;
while (letter_readed_counter != 0)
{
letter_readed_counter = read(file_descriptor, letters_readed, 10);
length = length + letter_readed_counter;
}
if (close(file_descriptor) == -1)
return (-1);
return (length);
}
char *ft_filereader(char *path)
{
char *str;
int file_descriptor;
int length;
length = ft_filelen(path);
if (length < 1)
{
str = malloc(sizeof(*str));
str[0] = '\0';
return (str);
}
str = malloc(sizeof(*str) * (length + 1));
file_descriptor = open(path, O_RDONLY);
if (file_descriptor == -1)
{
str[0] = '\0';
return (str);
}
read(file_descriptor, str, length);
str[length - 1] = '\0';
if (close(file_descriptor) == -1)
str[0] = '\0';
return (str);
}

View File

@ -0,0 +1,38 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atoapc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 20:57:44 by cchauvet #+# #+# */
/* Updated: 2022/07/31 20:58:47 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
char *ft_atoapc(char *str)
{
int i;
char *tab;
i = -1;
while (*str != ':')
str++;
str++;
while (*str == ' ')
str++;
tab = malloc(sizeof(*tab) * ft_strlen(str));
while (*str)
{
if (tab[i] == '\t')
tab[i] = ' ';
if (tab[i] == ' ' && str[1] == ' ')
while (str[0] == ' ')
str++;
tab[++i] = *str;
str++;
}
return (tab);
}

View File

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atoi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nlauvray <nlauvray@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 08:31:20 by nlauvray #+# #+# */
/* Updated: 2022/07/31 11:15:12 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
unsigned int ft_atoi(char *str)
{
int i;
unsigned int base;
i = 0;
base = 0;
while ('0' <= str[i] && str[i] <= '9')
base = base * 10 + (str[i++] - '0');
return (base);
}

View File

@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atonbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nlauvray <nlauvray@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 08:46:00 by nlauvray #+# #+# */
/* Updated: 2022/07/31 08:46:12 by nlauvray ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
char *ft_atonbr(char *str)
{
char *str_out;
int i;
i = 0;
while (str[i] >= '0' && str[i] <= '9')
i++;
str_out = malloc(sizeof(*str) * (i + 1));
i = 0;
while (str[i] >= '0' && str[i] <= '9')
{
str_out[i] = str[i];
i++;
}
str_out[i] = '\0';
return (str_out);
}

View File

@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_ctoa.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 18:41:31 by cchauvet #+# #+# */
/* Updated: 2022/07/31 22:42:20 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
char *ctoa(char c, unsigned int size)
{
char *str;
str = malloc(sizeof(char) * size);
str[0] = c;
str[1] = '\0';
return (str);
}

View File

@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_dict_error.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 20:41:33 by cchauvet #+# #+# */
/* Updated: 2022/07/31 20:55:47 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
int ft_dict_validator(char *path)
{
if (ft_dict_is_valid(path) == 0)
{
ft_putstr("Dict Error\n");
return (0);
}
return (1);
}

View File

@ -0,0 +1,35 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_dicterror.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 21:30:19 by cchauvet #+# #+# */
/* Updated: 2022/07/31 21:30:21 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
int ft_nbr_error(char *str)
{
int i;
i = -1;
while (str[++i] != ':')
{
if (!(str[i] >= '0' && str[i] <= '9') && str[i] != ' ')
return (0);
}
return (1);
}
int ft_print_dicterror(char *str)
{
if (ft_nbr_error(str) == 0)
{
return (0);
}
return (1);
}

View File

@ -0,0 +1,42 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_error.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nlauvray <nlauvray@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 08:39:29 by nlauvray #+# #+# */
/* Updated: 2022/07/31 08:40:57 by nlauvray ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
int ft_input_errors(char *str, char *tab)
{
int i;
i = -1;
while (str[++i])
{
if (str[i] != tab[i])
return (0);
}
return (1);
}
int ft_print_errors(char *str)
{
char *tab;
tab = malloc(sizeof(*tab) * ft_strlen(str));
tab = ft_tabnbr(ft_atoi(str));
if (ft_input_errors(str, tab) == 0)
{
free(tab);
write (1, "Error\n", 6);
return (0);
}
free(tab);
return (1);
}

View File

@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printapc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 19:14:04 by cchauvet #+# #+# */
/* Updated: 2022/07/31 19:21:42 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
void ft_printapc(char **tab, t_number *dict)
{
int i;
int j;
i = 0;
while (tab[i][0] != '\0')
{
j = 0;
while (ft_strcmp(tab[i], dict[j].nbr) != 0)
j++;
ft_putstr(dict[j].apc);
ft_putstr(" ");
i++;
}
ft_putstr("\n");
}

View File

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nlauvray <nlauvray@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 08:46:44 by nlauvray #+# #+# */
/* Updated: 2022/07/31 08:46:52 by nlauvray ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
#include <unistd.h>
void ft_putstr(char *str)
{
while (*str != 0)
write(1, str++, 1);
}

View File

@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_reverse_str.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nlauvray <nlauvray@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 08:35:22 by nlauvray #+# #+# */
/* Updated: 2022/07/31 08:35:29 by nlauvray ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
char *ft_reverse_str(char *str)
{
int i;
int size;
char tempo;
size = ft_strlen(str);
i = 0;
while (i < size / 2)
{
tempo = str[i];
str[i] = str[size - i - 1];
str[size - i - 1] = tempo;
i++;
}
return (str);
}

View File

@ -0,0 +1,41 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_split.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nlauvray <nlauvray@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 08:41:20 by nlauvray #+# #+# */
/* Updated: 2022/07/31 20:50:52 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
char **ft_split(char *str, char *sep)
{
char **tab;
int i;
int j;
int k;
i = 0;
j = 0;
tab = malloc(sizeof(*str) * ft_strlen(str));
while (str[i] != 0 && ft_strlen(str) > i)
{
k = i;
tab[j] = malloc(sizeof(**tab) * (i - k + ft_strstr(&str[i], sep) + 1));
while (i < k + ft_strstr(&str[k], sep))
{
tab[j][i - k] = str[i];
i++;
}
tab[j][i - k] = '\0';
i = k + ft_strstr(&str[k], sep) + ft_strlen(sep);
j++;
}
tab[j] = malloc(sizeof(char));
tab[j] = "";
return (tab);
}

View File

@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 18:35:08 by cchauvet #+# #+# */
/* Updated: 2022/07/31 22:40:07 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
char *cat(char *dest, char *src)
{
int i;
int j;
i = 0;
while (dest[i] != '\0')
i++;
j = 0;
while (src[j] != '\0')
{
dest[i + j] = src[j];
j++;
}
dest[i + j] = '\0';
return (dest);
}

View File

@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 19:17:11 by cchauvet #+# #+# */
/* Updated: 2022/07/31 21:00:11 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
int ft_strcmp(char *str1, char *str2)
{
while (*str1 == *str2 && *str1 != 0 && *str2)
{
str1++;
str2++;
}
return (*str1 - *str2);
}

View File

@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlen.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nlauvray <nlauvray@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 08:47:30 by nlauvray #+# #+# */
/* Updated: 2022/07/31 08:47:37 by nlauvray ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
int ft_strlen(char *str)
{
int i;
i = 0;
while (str[i] != 0)
i++;
return (i);
}

View File

@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nlauvray <nlauvray@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 08:35:51 by nlauvray #+# #+# */
/* Updated: 2022/07/31 12:37:19 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strstr(char *str, char *to_find)
{
unsigned int i;
unsigned int j;
i = 0;
while (str[i] != 0)
{
j = 0;
while (str[i + j] == to_find[j])
{
if (to_find[j + 1] == 0)
return (i);
j++;
}
i++;
}
return (i);
}

View File

@ -0,0 +1,33 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_tablen.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nlauvray <nlauvray@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 08:45:13 by nlauvray #+# #+# */
/* Updated: 2022/07/31 21:17:39 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
int ft_tablen(t_number *tab)
{
int i;
i = 0;
while (tab[i].nbr[0] != 0)
i++;
return (i);
}
int ft_lines_counter(char **strs)
{
int i;
i = 0;
while (strs[i][0] != 0)
i++;
return (i);
}

View File

@ -0,0 +1,47 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_tabnbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 20:57:07 by cchauvet #+# #+# */
/* Updated: 2022/07/31 20:57:09 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
int ft_lenght(unsigned int nb)
{
int a;
a = 1;
while (nb / 10 != 0)
{
nb = nb / 10;
a = a * 10;
}
return (a);
}
char *ft_tabnbr(unsigned int nb)
{
unsigned int nbr;
int a;
char *tab;
int i;
i = -1;
nbr = nb;
a = ft_lenght(nbr);
tab = malloc(sizeof(*tab) * a);
while (a != 0)
{
tab[++i] = nbr / a + 48;
nbr = nbr % a;
a = a / 10;
}
tab[++i] = '\0';
return (tab);
}

42
Rush/Rush02/ex00/main.c Normal file
View File

@ -0,0 +1,42 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 11:33:20 by cchauvet #+# #+# */
/* Updated: 2022/07/31 21:28:20 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
int main(int argc, char **argv)
{
t_number *dict;
char **tab;
int i;
i = 1;
if (!(argc >= 2 && argc <= 3))
{
write (1, "Error\n", 6);
return (0);
}
if (argc == 3)
{
i = 2;
if (ft_dict_validator(argv[1]) == 0)
return (0);
dict = ft_dictionnary_reader(argv[1]);
}
else
dict = ft_dictionnary_reader(PATH);
if (dict == NULL || ft_print_errors(argv[i]) == 0)
return (0);
tab = ft_decompose(argv[i]);
ft_printapc(tab, dict);
free(tab);
free(dict);
}

View File

@ -0,0 +1,41 @@
0: zero
1: one
2: two
3: three
4: four
5: five
6: six
7: seven
8: eight
9: nine
10: ten
11: eleven
12: twelve
13: thirteen
14: fourteen
15: fifteen
16: sixteen
17: seventeen
18: eighteen
19: nineteen
20: twenty
30: thirty
40: forty
50: fifty
60: sixty
70: seventy
80: eighty
90: ninety
100: hundred
1000: thousand
1000000: million
1000000000: billion
1000000000000: trillion
1000000000000000: quadrillion
1000000000000000000: quintillion
1000000000000000000000: sextillion
1000000000000000000000000: septillion
1000000000000000000000000000: octillion
1000000000000000000000000000000: nonillion
1000000000000000000000000000000000: decillion
1000000000000000000000000000000000000: undecillion

54
Rush/Rush02/ex00/rush02.h Normal file
View File

@ -0,0 +1,54 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rush02.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 10:32:28 by cchauvet #+# #+# */
/* Updated: 2022/07/31 22:42:06 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef RUSH02_H
# define RUSH02_H
# include <stdio.h>
# include <unistd.h>
# include <stdlib.h>
# include <sys/types.h>
# include <sys/stat.h>
# include <fcntl.h>
# define PATH "./numbers.dict"
# define LINES_NEED 41
struct s_number
{
char *nbr;
char *apc;
};
int ft_strcmp(char *str1, char *str2);
int ft_print_dicterror(char *str);
typedef struct s_number t_number;
char *cat(char *dest, char *src);
char *ctoa(char c, unsigned int size);
int ft_lines_counter(char **strs);
int ft_lenght(unsigned int nb);
int ft_dict_validator(char *path);
t_number *ft_dictionnary_reader(char *path);
int ft_dict_is_valid(char *path);
int ft_strstr(char *str, char *to_find);
char *ft_atonbr(char *str);
char *ft_atoapc(char *str);
char *ft_filereader(char *path);
char **ft_split(char *str, char *charset);
int ft_strlen(char *str);
int ft_tablen(t_number *tab);
unsigned int ft_atoi(char *str);
char *ft_reverse_str(char *str);
void ft_putstr(char *str);
char *ft_tabnbr(unsigned int nb);
int ft_print_errors(char *str);
void ft_printapc(char **tab, t_number *dict);
char **ft_decompose(char *nbr);
#endif

Binary file not shown.