first commit
This commit is contained in:
22
C08/ex00/ft.h
Normal file
22
C08/ex00/ft.h
Normal file
@ -0,0 +1,22 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ajoly <ajoly@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/08/03 11:02:39 by ajoly #+# #+# */
|
||||
/* Updated: 2022/08/04 09:32:35 by ajoly ### ########.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
|
26
C08/ex01/ft_boolean.h
Normal file
26
C08/ex01/ft_boolean.h
Normal file
@ -0,0 +1,26 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_boolean.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ajoly <ajoly@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/08/04 09:35:42 by ajoly #+# #+# */
|
||||
/* Updated: 2022/08/04 21:15:45 by ajoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef FT_BOOLEAN_H
|
||||
# define FT_BOOLEAN_H
|
||||
|
||||
# include <unistd.h>
|
||||
# define EVEN(x) x % 2 == 0
|
||||
# define EVEN_MSG "I have an even number of arguments.\n"
|
||||
# define ODD_MSG "I have an odd number of arguments.\n"
|
||||
# define TRUE 1
|
||||
# define FALSE 0
|
||||
# define SUCCESS 0
|
||||
|
||||
typedef int t_bool;
|
||||
|
||||
#endif
|
18
C08/ex02/ft_abs.h
Normal file
18
C08/ex02/ft_abs.h
Normal file
@ -0,0 +1,18 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_abs.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ajoly <ajoly@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/08/04 10:03:57 by ajoly #+# #+# */
|
||||
/* Updated: 2022/08/04 10:38:23 by ajoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef FT_ABS_H
|
||||
# define FT_ABS_H
|
||||
|
||||
# define ABS(x) (x > 0) ? x : -x
|
||||
|
||||
#endif
|
22
C08/ex03/ft_point.h
Normal file
22
C08/ex03/ft_point.h
Normal file
@ -0,0 +1,22 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_point.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ajoly <ajoly@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/08/04 10:40:55 by ajoly #+# #+# */
|
||||
/* Updated: 2022/08/04 10:47:01 by ajoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef FT_POINT_H
|
||||
# define FT_POINT_H
|
||||
|
||||
typedef struct s_point
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
} t_point;
|
||||
|
||||
#endif
|
67
C08/ex04/ft_strs_to_tab.c
Normal file
67
C08/ex04/ft_strs_to_tab.c
Normal file
@ -0,0 +1,67 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strs_to_tab.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ajoly <ajoly@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/08/04 10:52:25 by ajoly #+# #+# */
|
||||
/* Updated: 2022/08/04 21:46:09 by ajoly ### ########.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;
|
||||
|
||||
i = 0;
|
||||
while (src[i])
|
||||
i++;
|
||||
dest = malloc(i + 1);
|
||||
i = 0;
|
||||
while (src[i])
|
||||
{
|
||||
dest[i] = src[i];
|
||||
i++;
|
||||
}
|
||||
dest[i] = '\0';
|
||||
return (dest);
|
||||
}
|
||||
|
||||
struct s_stock_str *ft_strs_to_tab(int ac, char **av)
|
||||
{
|
||||
t_stock_str *tab;
|
||||
int i;
|
||||
|
||||
tab = malloc(sizeof(t_stock_str) * (ac + 1));
|
||||
if (tab == NULL)
|
||||
return (NULL);
|
||||
i = 0;
|
||||
while (i < ac)
|
||||
{
|
||||
tab[i].str = av[i];
|
||||
tab[i].copy = ft_strdup(tab[i].str);
|
||||
tab[i].size = ft_strlen(av[i]);
|
||||
i++;
|
||||
}
|
||||
tab[i].str = 0;
|
||||
tab[i].size = 0;
|
||||
tab[i].copy = 0;
|
||||
return (tab);
|
||||
}
|
Reference in New Issue
Block a user