我正在学习 c,这是“Head First C”一书中的一个练习,我的代码看起来与示例相同,但出现了上述错误。
#include <stdio.h>
typedef enum {
COUNT,POUNDS,PINTS
}unit_of_measure;
typedef union {
short count;
float weight;
float volume;
}quantity;
typedef struct{
const char *name;
const char *country;
quantity amount;
unit_of_measure units;
}fruit_order;
void display(fruit_order order)
{
printf("The order contains ");
if(order.amount==PINTS) //ERROR HERE
printf("%2.2f pints of %s\n",order.amount.weight, order.name);
else if(order.amount==POUNDS){ //ERROR HERE
printf("%2.2f lbss of %s\n",order.amount.weight, order.name);
else
printf("%i %s\n",order.amount.weight, order.name);
}
int main()
{
fruit_order apples = {"apples","Canada", .amount.count=100, COUNT};
fruit_order strawberries = {"strawberries","England", .amount.count=100, PINTS};
fruit_order oj = {"juice","USA", .amount.count=100, PINTS};
display(apples);
display(strawberries);
display(oj);
return 0;
}
这个错误是什么意思?