学了一个月的C语言,前几个在一本书中抄了一个C的超市管理系统的程序,可是编译的时候出了点问题,试了多种方法最后免强能用,但仍有很多不明的地方,希望各路过的大侠能指点一二!
程序的片段是这样的:
#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的吗?怎么会出现这样的问题呢!
还有就是能不能告诉我那个bioskey(0)是作什么用的?是不是用来返回到主函数的?