当前位置:网站首页>C language structure specifying initialization
C language structure specifying initialization
2022-04-23 06:48:00 【tilblackout】
Many times we don't use every member of the structure , Just want to initialize some of the members , At this time, you can use the specified initialization of the structure .
struct student {
char *name;
int num;
int age;
char group;
float score;
} ;
(1) Under normal circumstances : All variables must be initialized
struct student stu1 ={"Tom",12,18,"A",136.5};
(2) Specified initialization : Add a... Before the variable name “.”, Each line is separated by commas
struct student stu1={
.score=136.5,
.age=18,
.group="A",
} ;
example :
struct test{
int a;
char b;
};
struct test c[] = {// Create three members , Partial initialization
[0] = {
.a = 1,
},
[2] = {
.b = 'a',
},
};
版权声明
本文为[tilblackout]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230549282435.html
边栏推荐
- [stepping on the pit] MELD in win11 wsl2 cannot be used normally. Problem repair
- C语言实现memcpy、memset、strcpy、strncpy、strcmp、strncmp、strlen
- 微信小程序之改变数组中某值,对象中某值的方法
- Quaternion multiplication
- Error in created hook: “ReferenceError: “Promise”未定义“
- Joseph sequence segment tree o (nlogn)
- JS中 t, _ => 的解析
- Redux概述
- js获取链接?后边的参数名称或者值,根据url ?后的参数做判断
- Interprocess communication - mutex
猜你喜欢
查漏补缺(六)
元素计算距离与event事件对象
[UDS unified diagnosis service] i. diagnosis overview (3) - ISO 15765 architecture
CUDA project encountered a series of compilation problems after changing the environment (computer)
[UDS unified diagnostic service] IV. typical diagnostic service (5) - function / component test function unit (routine function unit 0x31)
VHDL finite state machine (FSM) code example
汇编 32位无符号加法计算器
JS中 t, _ => 的解析
cv_bridge 与opencv 版本不匹配的解决
VHDL arbitrary frequency divider (50% duty cycle)
随机推荐
FOC single resistance sampling position loop control servo motor
Interprocess communication - mutex
2022ldu winter vacation training - program patch
Makefile基础、常用函数及通用Makefile
汇编 32位无符号加法计算器
FOC SVPWM函数PWMC_SetPhaseVoltage解析
谈谈v-if显示隐藏问题
Assembly base code example
[UDS unified diagnostic service] II. Network layer protocol (1) - overview and functions of network layer
算数表达式
[UDS unified diagnostic service] III. application layer protocol (1)
监听除某元素之外点击事件
Makefile foundation, common functions and general makefile
The difference between single quotation mark, double quotation mark and back quotation mark in shell script
查漏补缺(一)
JS中的this指向
realsense 选型大对比D455 D435i D415 T265 3D硬件对比
Palindromic Primes
在visual stdio中运行qt程序
Palindromic Primes