use abs for values

This commit is contained in:
Pavol Rusnak 2011-04-22 05:47:10 +02:00
parent 3cbb55a2be
commit d86b9763c0
2 changed files with 4 additions and 3 deletions

View file

@ -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:

View file

@ -1,5 +1,6 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#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;