7.28 结构体 Day18

---note---

struct  student

{

  int num;char name[20];char sex;

  int age;float score;char addr[30];

}

struct 结构体名        scanf("%d",&stu1.num)

{                printf("%O",&stu1.num)

  成员表

} 变量名表

结构体数组

struct student 

{

  int num;

};struct student stu[3];

结构体变量.成员名  p->n

(*p).成员名     p->n++

p->成员名       ++p->n  p指向成员n的值加1

 

(++p)->num  先使P加1,然后得到它指向的元素中的num成员值

(p++)->num  先得到p->num

p=(struct student *)stu[0].name;

共用体:

共用体变量的地址和它的成员的地址都是同一地址

union 共用体名

几个不同变量名共同占用同一段内存的结构成为“共用体”

union data             union data

{                 {

int i;       或者        int i;

float f;                float f;

}a,b,c;               };

                  union data a,b,c;

枚举:将变量的值一一列举出来

enum  weekday {sunday,Monday,Tuesday,Wednesday,Friday,Thursday,Saturday}

 

enum  weekday  workday,weekday;

它们不是变量,不能赋值

可以用来作判断比较

 

typedef int   INTEGER

  typedef int num[10]

typedef int count ;#define count int 

---note---

posted on 2016-07-29 00:41  Dengyi  阅读(103)  评论(0编辑  收藏  举报

导航