按照8楼的建议我也试了一下,可是加了struct 之后,后面编译它又会出现新的问题,这个问题我已经发贴问过了,可是没人说得清!
差不多就是下面这样,很晕啊,现在!
程序的片段是这样的:
#include<stdio.h>
#include<string.h>
#define MAX 20
……
……
int sum; /*用来记录商品数目*/
/*日期结构体类型*/
struct datetime
{ int year;
int month;
int date;
};
/*商品结构体类型*/
struct goods_type
{ int num;
char name[10];
char kind[10];
int amount;
int goods_up;
int goods_down;
int in_price;
int out_price;
int in_num;
struct datetime in_time;
struct datetime pro_time;
char factory[10];
int save_day;
int profit;
}goods[MAX]; /*存放MAX种商品记录的结构体数组*/
/*输入模块*/
input_message()
{ int i=0,s=MAX;
clrscr();
printf("\n\n 录入商品信息 (最多%d种)\n",s);
printf(" -------------------------------\n");
do
{printf("\n 第%d种商品",i+1);
printf("\n 商品号:");
scanf("%d",&goods[i].num);
if(goods[i].num==0) break;
printf("\n 商品名称:");
scanf("%s",goods[i].name);
printf("\n 商品类别:");
scanf("%s",goods[i].kind);
printf("\n 商品总量:");
scanf("%d",&godds[i].amount);
printf("\n 商品上限:");
scanf("%d",&goods[i].goods_up);
printf("\n 商品下限:");
scanf("%d",&goods[i].goods_down);
printf("\n 进货价格:");
scanf("%d",&goods[i].in_price);
printf("\n 销售价格:");
scanf("%d",&goods[i].out_price);
printf("\n 进货数量:");
scanf("%d",&goods[i].in_num);
printf("\n 进货日期(yyyy-mm-dd):");
scanf("%d%d%d",&goods[i].in_time.year,&goods[i].in_time.month,&goods[i].in_time.date);
printf("\n 生产日期(yyyy-mm-dd):");
scanf("%d%d%d",%goods[i].pro_time.year,%goods[i].pro_time.month,&goods[i].pro_time.date);
printf("\n 生产厂家:");
scanf("%s",goods[i].factory);
printf("\n 保质期:");
scanf("%d",&goods[i].save_day);
i++;
}while(i<MAX);
printf("\n --%d种商品信息输入完毕!--\n",i);
sum=i;
printf("\n 按任意键返回主菜单!");
bioskey(0);
}
但是用VC++编译的时候却出现了下面这样的问题
left of '.name' must have class/struct/union type
left of '.kind' must have class/struct/union type
left of '.out_prince' must have class/struct/union type
left of '.pro_time' must have class/struct/union type
left of '.year' must have class/struct/union type
left of '.pro_time' must have class/struct/union type
left of '.month' must have class/struct/union type
left of '.pro_time' must have class/struct/union type
left of '.date' must have class/struct/union type
left of '.save_day' must have class/struct/union type
left of '.num' must have class/struct/union type
left of '.name' must have class/struct/union type
最后又换了TC2。0也是出现了点问题,改用WIN—TC才解决问题,可是我就不是很明白,VC++不是也可以用来编译C的吗?怎么会出现这样的问题呢!