打印

请教关于结构体的头文件怎么定义及使用?

[复制链接]
2938|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
shyboy1212|  楼主 | 2007-10-8 11:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
请问大虾,如果要定义一个共用体,并且要能够被多个.c程序使用,可以将其定义成一个头文件,是否直接在头文件中定
义?引用怎么引用?
//struct.h
struct Statistice
{
 uint   stat_tol ;
 uint   stat_pass;
 uint   stat_high;
 uint   stat_low ;
 float    stat_std ;
 float  stat_yld ;
}stat_data;

//main.c
#include"struct.h"
下面怎么引用?
是否可以直接使用如:stat_data.stat_std=0;

相关帖子

沙发
ayb_ice| | 2007-10-8 11:17 | 只看该作者

找书看

使用特权

评论回复
板凳
农民讲习所| | 2007-10-8 12:34 | 只看该作者

:

//struct.h
struct Statistice
{
uint   stat_tol ;
uint   stat_pass;
uint   stat_high;
uint   stat_low ;
float    stat_std ;
float  stat_yld ;
};

*注意一定要分开写!
extern struct Statistice stat_data;

//struct.c
struct Statistice stat_data;


//main.c
#include"struct.h"
下面怎么引用?
是否可以直接使用如:stat_data.stat_std=0;

把struct Statistice想象为==char

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

17

主题

36

帖子

0

粉丝