From d86b9763c09a771a069845f705705bae3d48b5cf Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Fri, 22 Apr 2011 05:47:10 +0200 Subject: [PATCH] use abs for values --- Makefile | 2 +- brmbar.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 6460a62..ac4be44 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ CC=bcc CFLAGS=-Md -W all: brmbar.c -# gcc brmbar.c dataio.c -o brmbar +# gcc -Wall brmbar.c dataio.c -o brmbar bcc -Md -W brmbar.c dataio.c -o brmbar.com clean: diff --git a/brmbar.c b/brmbar.c index 46ff12c..aaf1c1e 100644 --- a/brmbar.c +++ b/brmbar.c @@ -1,5 +1,6 @@ #include #include +#include #include "dataio.h" #define EAN_MAXLEN 32 @@ -99,7 +100,7 @@ void read_input() if (!strncmp(buf, items[i].ean, strlen(items[i].ean)) && strlen(items[i].ean)+1 == strlen(buf)) { if (items[i].price) { last_item = i; - printf("\n%s %d Kc\n\n", items[i].name, items[i].price); + printf("\n%s %d Kc\n\n", items[i].name, abs(items[i].price)); } else { last_item = -1; printf("\n%s\n\n", items[i].name); @@ -117,7 +118,7 @@ void read_input() printf("has %d Kc.\n\n", balance); } else { balance = modify_credit(people[i], items[last_item].price); - printf("has ordered %s for %d Kc and now has %d Kc.\n\n", items[last_item].name, items[last_item].price, balance); + printf("has ordered %s for %d Kc and now has %d Kc.\n\n", items[last_item].name, abs(items[last_item].price), balance); last_item = -1; } return;