| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 782 人关注过本帖
标题:求助一个有关struct在VC++中应用的问题
只看楼主 加入收藏
gang
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2006-2-28
收藏
 问题点数:0 回复次数:1 
求助一个有关struct在VC++中应用的问题

学了一个月的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的吗?怎么会出现这样的问题呢!

搜索更多相关主题的帖子: struct int 商品 MAX 结构体 
2006-03-01 17:25
gang
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2006-2-28
收藏
得分:0 
  怎么没人回我?自己顶一个

一个来自华南师大通信工程的菜鸟,只学过一点学校教的C++和自学了一点C,大家不要笑他!哈哈……
2006-03-01 22:42
快速回复:求助一个有关struct在VC++中应用的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014652 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved