试图让我周围的旧的C语言头。目前在结构和收到此错误:C:变量初始化,但不完全类型
"variable 'item1' has initializer but incomplete type"
这里是我的代码:
typedef struct
{
int id;
char name[20];
float rate;
int quantity;
} item;
void structsTest(void);
int main()
{
structsTest();
system("PAUSE");
return 0;
}
void structsTest(void)
{
struct item item1 = { 1, "Item 1", 345.99, 3 };
struct item item2 = { 2, "Item 2", 35.99, 12 };
struct item item3 = { 3, "Item 3", 5.99, 7 };
float total = (item1.quantity * item1.rate) + (item2.quantity * item2.rate) + (item3.quantity * item3.rate);
printf("%f", total);
}
我猜也许是结构确定指标是在错误的位置,所以我把它移动到文件并重新编译的顶部,但我仍然遇到同样的错误。我的错误在哪里?