Browse Source

Call to errorMessage() with error code -12 in collectCustomerProperties if the user enters too many digits for the account balance.

remotes/origin/development
fdai7057 2 years ago
parent
commit
1d49c20634
  1. 8
      src/createCustomer.c
  2. 5
      src/error.c

8
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 && (userInput=getchar())!='\n'){
while(letterCounter<=letterMaximum && (userInput=getchar())!='\n'){
*(balanceCharacters+letterCounter) = userInput;
++letterCounter;
if(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) = '.';

5
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.");
}

Loading…
Cancel
Save