blob: c29b6efc6f431d56fc3ba8e2791f02522a1a61c2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/07/17 07:29:52 by cacharle #+# #+# */
/* Updated: 2019/07/18 10:38:57 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
#include "include.h"
int main(int argc, char **argv)
{
int x;
int y;
int operator_index;
int (*operators[5])(int, int);
operators[0] = &add;
operators[1] = &subtract;
operators[2] = &multiply;
operators[3] = ÷
operators[4] = &modulo;
operator_index = parse(argc, argv);
if (operator_index == -1)
return (0);
if (operator_index == -2)
ft_putchar('0');
else
{
x = ft_atoi(argv[1]);
y = ft_atoi(argv[3]);
if (check_floating_point_error(operator_index, y) == -1)
return (0);
ft_putnbr((*operators[operator_index])(x, y));
}
ft_putchar('\n');
return (0);
}
|