0
0
This commit is contained in:
2021-08-20 23:13:19 +02:00
parent 0c39ec556e
commit 50defa6766
4 changed files with 72 additions and 3 deletions

View File

@@ -1,8 +1,8 @@
#!/bin/sh
set -e
#norminette -R CheckForbiddenSourceHeader ft_*.c
norminette -R CheckDefine -R CheckForbiddenSourceHeader *.c
norminette -R CheckDefine *.h
norminette -R CheckForbiddenSourceHeader *.c
gcc -Wall -Wextra -Werror -o a.out *.c
echo $(basename $PWD):
./a.out
./a.out "$@"
rm -f a.out

View File

@@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_boolean.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_BOOLEAN_H
# define FT_BOOLEAN_H
# include <unistd.h>
typedef int t_bool;
# define TRUE 0
# define FALSE 1
# 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"
# define SUCCESS 0
#endif

34
C_08/git/ex01/main.c Normal file
View File

@@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* 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_boolean.h"
void ft_putstr(char *str)
{
while (*str)
write(1, str++, 1);
}
t_bool ft_is_even(int nbr)
{
return ((EVEN(nbr)) ? TRUE : FALSE);
}
int main(int argc, char **argv)
{
(void) argv;
if (ft_is_even(argc - 1) == TRUE)
ft_putstr(EVEN_MSG);
else
ft_putstr(ODD_MSG);
return (SUCCESS);
}

9
C_08/git/ex01/main.sh Executable file
View 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