commit
This commit is contained in:
26
C_08/git/ex01/ft_boolean.h
Normal file
26
C_08/git/ex01/ft_boolean.h
Normal 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
34
C_08/git/ex01/main.c
Normal 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
9
C_08/git/ex01/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
|
||||
Reference in New Issue
Block a user