From d6a3c7a93268fede146424c4e5d47d50c351be5d Mon Sep 17 00:00:00 2001 From: Live session user Date: Mon, 31 Dec 2018 12:58:03 +0000 Subject: [PATCH 1/2] operator ^ fix --- calc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/calc.c b/calc.c index dca5452..25e319d 100644 --- a/calc.c +++ b/calc.c @@ -33,7 +33,7 @@ static struct token* opStack; static int outCount; static double* outStack; -static const int binary[] = { 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; +static const int binary[] = { 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 }; static const int precedence[] = { 0, 0, 1, 1, 1, 2, 3, 4, 4, 5 }; static const int association[] = { 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; @@ -91,7 +91,7 @@ int execute(struct token temp) { case '%': result = fmod(d1, d2); break; - case '#': + case '^': result = pow(d1, d2); break; } @@ -106,7 +106,7 @@ int execute(struct token temp) { d1 = outStack[--outCount]; switch(temp.subType) { - case '_': + case '_': result = d1; break; case '~': From bf6a4f24a5533e7c868917a004decf0cc22b51a7 Mon Sep 17 00:00:00 2001 From: Live session user Date: Mon, 7 Jan 2019 10:39:50 +0000 Subject: [PATCH 2/2] added new Makefile to the project --- Makefile | 20 ++++++++++++++++++++ calc.c | 2 ++ 2 files changed, 22 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..37b3172 --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +CC=gcc + +CFLAGS= -c -Wall + +all: prog + +prog: calc.o helpers.o + $(CC) -std=c99 -o prog helpers.o calc.o -lm + +calc.o: calc.c + $(CC) $(CFLAGS) calc.c + +helpers.o: helpers.c + $(CC) $(CFLAGS) helpers.c + +install: + cp ./prog /usr/local/bin +clean: + rm -rf *.o + diff --git a/calc.c b/calc.c index 25e319d..1ef3cd1 100644 --- a/calc.c +++ b/calc.c @@ -5,6 +5,8 @@ #include #include + + #include "struct.h" #include "helpers.h"