【5】#define与typedef,typedef struct

typedef和define具体的详细区别

2,C语言结构体初始化的四种方法

3,struct和typedef struct彻底明白了

4,

#include <stdio.h>
typedef struct student
{
	int a;
	int b;
	int c;
}XS;   //XS==struct student 所以定义变量可以是 XS t11; struct student t12; // t111==t12;

typedef struct 
{
	int a;
	int b;
	int c;
}XSS;

int main()
{
	XS t1={
		.a=2,
		.b=5,
		.c=18,	
			};
	struct student t2={
		.a=61,
		.b=63,
		.c=168,	
			};

	XSS t3={
		.a=5,
		.b=7,
		.c=198,	
			};
   printf("a=%5d  b=%5d  c=%5d \n",t1.a,t1.b,t1.c);
   printf("a=%5d  b=%5d  c=%5d \n",t2.a,t2.b,t2.c);	
   printf("a=%5d  b=%5d  c=%5d \n",t3.a,t3.b,t3.c);
   
   return 0;
}

运行的结果

猜你喜欢

转载自blog.csdn.net/qq_40662854/article/details/82769128