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

21
C/c08v1/ex00/ft.h Normal file
View File

@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/26 19:22:59 by cchauvet #+# #+# */
/* Updated: 2022/07/27 09:42:01 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FT_H
# define FT_H
void ft_putchar(char c);
void ft_swap(int *a, int *b);
void ft_putstr(char *str);
int ft_strlen(char *str);
int ft_strcmp(char *s1, char *s2);
#endif

25
C/c08v1/ex01/ft_boolean.h Normal file
View File

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_boolean.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/26 19:25:57 by cchauvet #+# #+# */
/* Updated: 2022/08/03 17:22:14 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FT_BOOLEAN_H
# define FT_BOOLEAN_H
# include <unistd.h>
typedef int t_bool;
# define TRUE 1
# define FALSE 0
# define SUCCESS 0
# define EVEN(nbr) nbr % 2 == 0
# define EVEN_MSG "I have an even number of arguments.\n"
# define ODD_MSG "I have an odd number of arguments.\n"
#endif

18
C/c08v1/ex02/ft_abs.h Normal file
View File

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_abs.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/26 19:36:46 by cchauvet #+# #+# */
/* Updated: 2022/08/03 17:25:46 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FT_ABS_H
# define FT_ABS_H
# define ABS(Value) (Value * ((Value > 0) - (Value < 0)))
#endif

20
C/c08v1/ex03/ft_point.h Normal file
View File

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_point.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/27 09:24:28 by cchauvet #+# #+# */
/* Updated: 2022/07/27 18:02:43 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FT_POINT_H
# define FT_POINT_H
typedef struct s_point
{
int x;
int y;
} t_point;
#endif

View File

@ -0,0 +1,58 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strs_to_tab.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/27 09:28:54 by cchauvet #+# #+# */
/* Updated: 2022/08/03 17:27:47 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "ft_stock_str.h"
int ft_strlen(char *str)
{
int i;
i = 0;
while (str[i] != 0)
i++;
return (i);
}
char *ft_strdup(char *src)
{
int i;
char *dest;
dest = malloc(sizeof(*dest) * ft_strlen(src));
i = 0;
while (src[i] != 0)
{
dest[i] = src[i];
i++;
}
dest[i] = 0;
return (dest);
}
t_stock_str *ft_strs_to_tab(int ac, char **av)
{
int i;
t_stock_str *tab;
tab = malloc(sizeof(*tab) * (ac + 1));
i = 0;
while (i < ac)
{
tab[i].size = ft_strlen(av[i]);
tab[i].str = av[i];
tab[i].copy = ft_strdup(av[i]);
i++;
}
tab[i].str = "";
return (tab);
}

View File

@ -0,0 +1,49 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_show_tab.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/27 18:54:39 by cchauvet #+# #+# */
/* Updated: 2022/08/03 17:28:11 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
#include "ft_stock_str.h"
void ft_putchar(char c)
{
write(1, &c, 1);
}
void ft_print_str(char *str)
{
while (*str != 0)
write(1, str++, 1);
ft_putchar('\n');
}
void ft_print_nbr(int nbr)
{
if (nbr > 9)
{
ft_print_nbr(nbr / 10);
ft_print_nbr(nbr % 10);
}
else
ft_putchar(nbr + 48);
}
void ft_show_tab(struct s_stock_str *par)
{
while (par->str[0] != 0)
{
ft_print_str(par->str);
ft_print_nbr(par->size);
ft_putchar('\n');
ft_print_str(par->copy);
par++;
}
}