c语言(结构体篇)

struct list{   //声明一个list的结构体
		int count;
		int number;
		int digit;
};


void main()
{
    struct list person={1,2,3};	
    //在list结构体的基础上创建一个person变量 值与上面的count,number,digit一一对应
	printf("count=%d\n",person.count); //1
}

使用typedef简写

//使用typedef 简写

//typedef是在计算机编程语言中用来为复杂的声明定义简单的别名

typedef struct list{
		int count;
		int number;
		int digit;
}job;


void main()
{	
	job person={1,2,3};	
	printf("count=%d\n",person.count); //1
}

猜你喜欢

转载自blog.csdn.net/zero_person_xianzi/article/details/82113684