结构体

结构体类型的定义

#include<stdio.h>
#include<math.h>
#define e 2.718
//typedef int INTEGER 别名
int main(){
	//1 
	struct student{
		int num;
		char name[8];
		float score;
	};//先声明类型,后定义变量 
	
	
	struct student a,*b,c[3];
	//2//说明结构体类型的同时,然后定义结构体的变量
	struct student1{
		int num;
		char name[8];
		float score;
	}d,f;
	//3 直接定义结构体变量 没有结构体类型名	
	struct {
		int num;
		char name[9];
	}f,g;

	//使用用户自定义类型定义
	typedef struct student2{
		int num;
		char name[3];

	}STD;
	return 0;



}

结构体的初始化

变量的初始化

struct {
int a;
float b;
}s={12,24,34};

结构体数组的初始化

struct data
{
int x;
int y;

}c[3]={12,23,22,33,22,33};
posted @ 2023-03-16 21:13  Development_UP  阅读(11)  评论(0)    收藏  举报