commit
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_boolean.h :+: :+: :+: */
|
/* ft_point.h :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
|
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
@@ -10,9 +10,13 @@
|
|||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef FT_ABS_H
|
#ifndef FT_POINT_H
|
||||||
# define FT_ABS_H
|
# define FT_POINT_H
|
||||||
|
|
||||||
# define ABS(Value) ((Value < 0)? (-Value): (Value))
|
|
||||||
|
|
||||||
|
typedef struct s_point
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
} t_point;
|
||||||
|
void set_point(t_point *point);
|
||||||
#endif
|
#endif
|
||||||
@@ -10,41 +10,18 @@
|
|||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "ft_abs.h"
|
#include "ft_point.h"
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
static int ft_atoi(char *str)
|
void set_point(t_point *point)
|
||||||
{
|
{
|
||||||
int nb;
|
point->x = 42;
|
||||||
int s;
|
point->y = 21;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(void)
|
||||||
{
|
{
|
||||||
int n;
|
t_point point;
|
||||||
|
|
||||||
(void) argc;
|
set_point(&point);
|
||||||
n = ft_atoi(argv[1]);
|
|
||||||
printf("%d\n", ABS(n));
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
22
C_08/git/ex04/ft_point.h
Normal file
22
C_08/git/ex04/ft_point.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_point.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2021/08/20 10:17:09 by gbaconni #+# #+# */
|
||||||
|
/* Updated: 2021/08/20 12:05:50 by gbaconni ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#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
|
||||||
27
C_08/git/ex04/main.c
Normal file
27
C_08/git/ex04/main.c
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* main.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2021/08/20 10:26:50 by gbaconni #+# #+# */
|
||||||
|
/* Updated: 2021/08/20 10:34:14 by gbaconni ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "ft_point.h"
|
||||||
|
|
||||||
|
void set_point(t_point *point)
|
||||||
|
{
|
||||||
|
point->x = 42;
|
||||||
|
point->y = 21;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
t_point point;
|
||||||
|
|
||||||
|
set_point(&point);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
9
C_08/git/ex04/main.sh
Executable file
9
C_08/git/ex04/main.sh
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
norminette -R CheckDefine *.h
|
||||||
|
norminette -R CheckForbiddenSourceHeader ft_*.c
|
||||||
|
cpp main.c
|
||||||
|
gcc -Wall -Wextra -Werror -o a.out *.c
|
||||||
|
echo $(basename $PWD):
|
||||||
|
./a.out "$@"
|
||||||
|
rm -f a.out
|
||||||
14
ex.sh
Executable file
14
ex.sh
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
ex=${1:?$0 <ex??>}
|
||||||
|
shift
|
||||||
|
rm -f a.out
|
||||||
|
find ../${ex} -type f -name '*.h' -exec \
|
||||||
|
norminette -R CheckDefine {} \;
|
||||||
|
find ../${ex} -type f -name '*.c' \! -name 'main.c' -exec \
|
||||||
|
norminette -R CheckForbiddenSourceHeader {} \;
|
||||||
|
#gcc ${ex}.c
|
||||||
|
gcc -Wall -Wextra -Werror -o a.out ${ex}.c
|
||||||
|
echo ${ex}:
|
||||||
|
./a.out "$@"
|
||||||
|
rm -f a.out
|
||||||
Reference in New Issue
Block a user