void display(fruit_order order)
{
printf("The order contains ");
if(order.units==PINTS) {
printf("%2.2f pints of %s\n",order.amount.weight, order.name);
}
else if(order.units==POUNDS){
printf("%2.2f lbss of %s\n",order.amount.weight, order.name);
}
else {
printf("%i %s\n",order.amount.weight, order.name);
}
}
units
is unit_of_measure
, we should use order.units==PINTS
; And I recommend we always use {}
in if
statement to make the code clearer. I just noticed the original code has missing bracket.