From 1d49c206349507e59abb2397cc6a703c1ce60560 Mon Sep 17 00:00:00 2001 From: fdai7057 Date: Sat, 4 Feb 2023 20:22:36 +0100 Subject: [PATCH] Call to errorMessage() with error code -12 in collectCustomerProperties if the user enters too many digits for the account balance. --- src/createCustomer.c | 8 +++----- src/error.c | 5 +++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/createCustomer.c b/src/createCustomer.c index 7dd6aa2..af52cb3 100644 --- a/src/createCustomer.c +++ b/src/createCustomer.c @@ -77,18 +77,16 @@ void collectCustomerProperties() printf("Enter balance (max. 10 digits):\n"); char *balanceCharacters = calloc(10+1+1+1,sizeof(char)); letterMaximum = 10; - while(letterCounter=letterMaximum){ + if(letterCounter>letterMaximum){ inputTooLong = true; break; } } if(inputTooLong){ - puts("Input too long."); - exit(-1); - //call errorMessage(-10); + errorMessage(-12); }else{ if(!foundComma){ *(balanceCharacters+letterCounter) = '.'; diff --git a/src/error.c b/src/error.c index dc22300..3765a32 100644 --- a/src/error.c +++ b/src/error.c @@ -55,6 +55,11 @@ int errorMessage(int errorCode) returnValue = -11; exit(-1); break; + case -12: + puts("You entered too many digits."); + returnValue = -12; + exit(-1); + break; default: puts("Error code unknown."); }