0
0
This commit is contained in:
2021-08-21 20:25:38 +02:00
parent 7d29fa524b
commit 3e92d6c4a6
6 changed files with 88 additions and 35 deletions

View File

@@ -1,7 +1,7 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_boolean.h :+: :+: :+: */
/* ft_point.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
@@ -10,9 +10,13 @@
/* */
/* ************************************************************************** */
#ifndef FT_ABS_H
# define FT_ABS_H
# define ABS(Value) ((Value < 0)? (-Value): (Value))
#ifndef FT_POINT_H
# define FT_POINT_H
typedef struct s_point
{
int x;
int y;
} t_point;
void set_point(t_point *point);
#endif

View File

@@ -10,41 +10,18 @@
/* */
/* ************************************************************************** */
#include "ft_abs.h"
#include <stdio.h>
#include "ft_point.h"
static int ft_atoi(char *str)
void set_point(t_point *point)
{
int nb;
int s;
int i;
nb = 0;
s = 1;
i = 0;
while (str[i] != '\0' && (str[i] == ' ' || (str[i] >= '\t' && str[i] <= '\r')))
i++;
while (str[i] != '\0')
{
if (str[i] == '+')
s += 0;
else if (str[i] == '-')
s *= -1;
else if (str[i] >= '0' && str[i] <= '9')
nb = nb * 10 + str[i] - '0';
else
break ;
i++;
}
return (nb * s);
point->x = 42;
point->y = 21;
}
int main(int argc, char *argv[])
int main(void)
{
int n;
t_point point;
(void) argc;
n = ft_atoi(argv[1]);
printf("%d\n", ABS(n));
set_point(&point);
return (0);
}