aboutsummaryrefslogtreecommitdiff
path: root/c11/ex05/parse.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2019-07-19 07:04:04 +0200
committerCharles <sircharlesaze@gmail.com>2019-07-19 07:04:04 +0200
commit8b6e91bdb56bc01a588718472546f2a88e750b48 (patch)
tree654ba9e8216c688bb3d6a2e5d67526ae8ec4b874 /c11/ex05/parse.c
parent880102ae9358db130ef67cc9a7177a1e1de76875 (diff)
downloadpiscine-8b6e91bdb56bc01a588718472546f2a88e750b48.tar.gz
piscine-8b6e91bdb56bc01a588718472546f2a88e750b48.tar.bz2
piscine-8b6e91bdb56bc01a588718472546f2a88e750b48.zip
c10 done?, c11 moulinetted (ex04, ex06 need correction)
Diffstat (limited to 'c11/ex05/parse.c')
-rw-r--r--c11/ex05/parse.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/c11/ex05/parse.c b/c11/ex05/parse.c
index 5b1c531..1540945 100644
--- a/c11/ex05/parse.c
+++ b/c11/ex05/parse.c
@@ -6,10 +6,12 @@
/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/07/17 08:05:59 by cacharle #+# #+# */
-/* Updated: 2019/07/17 08:35:50 by cacharle ### ########.fr */
+/* Updated: 2019/07/18 10:40:34 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
+#include <unistd.h>
+
int parse(int argc, char **argv)
{
int i;
@@ -27,13 +29,21 @@ int parse(int argc, char **argv)
else if (argv[2][0] == '%')
i = 4;
else
- i = -2;
+ i = -2;
return (i);
}
-/*int make_operation(int x, int y, int (*operator)(int, int))*/
-/*{*/
-
- /*retu*/
-
-/*}*/
+int check_floating_point_error(int operator_index, int y)
+{
+ if (operator_index == 3 && y == 0)
+ {
+ write(1, "Stop : division by zero\n", 24);
+ return (-1);
+ }
+ if (operator_index == 4 && y == 0)
+ {
+ write(1, "Stop : modulo by zero\n", 22);
+ return (-1);
+ }
+ return (0);
+}