当前位置:网站首页>C语言结构体指定初始化
C语言结构体指定初始化
2022-04-23 05:50:00 【tilblackout】
很多时候我们并不会使用到结构体中每一个成员,只想初始化其中某几个成员,这时候可以使用结构体的指定初始化。
struct student {
char *name;
int num;
int age;
char group;
float score;
} ;
(1)常规情况下:所有变量都要初始化
struct student stu1 ={"Tom",12,18,"A",136.5};
(2)指定初始化:在变量名前加一个“.”,每行用逗号隔开
struct student stu1={
.score=136.5,
.age=18,
.group="A",
} ;
例:
struct test{
int a;
char b;
};
struct test c[] = {//创建三个成员,部分初始化
[0] = {
.a = 1,
},
[2] = {
.b = 'a',
},
};
版权声明
本文为[tilblackout]所创,转载请带上原文链接,感谢
https://blog.csdn.net/tilblackout/article/details/123419304
边栏推荐
- 对象的动态建立和释放,赋值和复制
- Object array and object pointer
- Introduction to nonparametric camera distortion model
- [ThreadX] ThreadX source code reading plan (I)
- Camera calibration: key point method vs direct method
- 对象数组与对象指针
- Completely clean up MySQL win
- Make your own small program
- [opencv] use filestorage to read and write eigenvectors
- 安装pyshp库
猜你喜欢

Graduation project, viewing screenshots of epidemic psychological counseling system

如何安装jsonpath包

Call procedure of function

基于SSD的物体检测案例实现
![[UDS unified diagnosis service] IV. typical diagnosis service (3) - read fault information function unit (storage data transmission function unit)](/img/10/bd39bb03f5456a412650596208a391.png)
[UDS unified diagnosis service] IV. typical diagnosis service (3) - read fault information function unit (storage data transmission function unit)

ArcGIS表转EXCEL超出上限转换失败

PHP junior programmers, take orders and earn extra money
![[UDS unified diagnosis service] i. diagnosis overview (2) - main diagnosis protocols (K-line and can)](/img/ec/9b783b6dca5684684485e3b9fc6846.png)
[UDS unified diagnosis service] i. diagnosis overview (2) - main diagnosis protocols (K-line and can)
![C [document operation] PDF files and pictures are converted to each other](/img/6b/0742aa3eb45fbca091d6d20bc55326.png)
C [document operation] PDF files and pictures are converted to each other

【UDS统一诊断服务】五、诊断应用示例:Flash Bootloader
随机推荐
Wechat applet request encapsulation
Matching between class template with default template argument and template parameter
【UDS统一诊断服务】(补充)五、ECU bootloader开发要点详解 (1)
C语言进阶要点笔记5
C#【文件操作篇】PDF文件和图片互相转换
WMI技术介绍和应用
静态成员
Static member
Feign请求日志统一打印
非参数化相机畸变模型简介
LaTeX配置与使用
grub boot. S code analysis
Excel打开超大csv格式数据
【学习一下】HF-Net 训练
Opencv uses genericindex for KNN search
C语言实现2048小游戏方向合并逻辑
[UDS unified diagnostic service] i. overview of diagnosis (4) - basic concepts and terms
生成验证码
[UDS unified diagnostic service] III. application layer protocol (1)
【UDS统一诊断服务】二、网络层协议(2)— 数据传输规则(单帧与多帧)