typedef struct
来源:互联网 发布:淘宝看戏机哪个牌子好 编辑:程序博客网 时间:2024/04/28 22:36
step 1:
#exaple
struct girl
{
int age;
int weight;
int height;
struct girl *next/*特别注意结构体指针*/
};
-------->struct是申明结构体类型是所必须使用的关键字,不能省略
-------->girl为结构体名,可以省略!
-------->struct girl是一个类型名,它就和int,char,float,double差不多
通用形式是:
struct 结构体名
{成员列表};
step 2:
结构类型变量的说明
1. 先定义结构,再说明结构变量
struct stu
{
int num;
char name[20];
char sex;
float score;
};
struct stu boy1,boy2;
2.在定义结构类型的同时说明结构变量
struct stu
{
int num;
char name[20];
char sex;
float score;
}stu boy1,boy2;
3.直接说明结构变量
struct/*注意此处省略了结构体名*/
{
int num;
char name[20];
char sex;
float score;
}stu boy1,boy2;
4.成员也可以又是一个结构
struct date
{
int month;
int day;
int year;
};
struct
{
int num;
char name[20];
char sex;
struct date birthday;
float score;
}boy1,boy2;
#exaple
struct girl
{
int age;
int weight;
int height;
struct girl *next/*特别注意结构体指针*/
};
-------->struct是申明结构体类型是所必须使用的关键字,不能省略
-------->girl为结构体名,可以省略!
-------->struct girl是一个类型名,它就和int,char,float,double差不多
通用形式是:
struct 结构体名
{成员列表};
step 2:
结构类型变量的说明
1. 先定义结构,再说明结构变量
struct stu
{
int num;
char name[20];
char sex;
float score;
};
struct stu boy1,boy2;
2.在定义结构类型的同时说明结构变量
struct stu
{
int num;
char name[20];
char sex;
float score;
}stu boy1,boy2;
3.直接说明结构变量
struct/*注意此处省略了结构体名*/
{
int num;
char name[20];
char sex;
float score;
}stu boy1,boy2;
4.成员也可以又是一个结构
struct date
{
int month;
int day;
int year;
};
struct
{
int num;
char name[20];
char sex;
struct date birthday;
float score;
}boy1,boy2;
step 3:
typedef的用法
typedef定义的一般形式为:
ypedef 原类型名 新类型名
typedef struct stu
{
char name[20];
int age;
char sex;
} STU;
定义STU表示struct stu 别名,然后可用STU来说明结构变量:
STU body1,body2;
STU *next;
- typedef struct
- typedef struct
- typedef struct
- typedef struct
- Struct && typedef
- struct / typedef
- typedef struct
- typedef struct
- typedef struct
- typedef struct
- typedef struct
- typedef 与 typedef struct
- typedef与typedef struct
- struct和typedef struct
- struct和typedef struct
- struct和typedef struct
- struct 和 typedef struct
- struct和typedef struct
- C++ STL标准容器插入删除算法的复杂度(来源flyhorse)
- Suse Linux Enteprise Server 10的内核升级
- 关于IE控件frameset导致GDI对象泄漏的问题
- Axis开发web services
- IMSI和TIMSI
- typedef struct
- 正则表示式基本语法
- 指向指针的指针(整理)
- minisap安装
- 获得字段的注释SQL
- 网站下拉菜单,选择下拉后自动填充(图)
- 大学生创业三大忌讳
- JarRun: 将Jar打包成EXE发布到没有装Java的电脑上运行,一步搞定!
- mplayer 错误 failed to open file:///路径.rmvb