当前位置:网站首页>C language flexible array
C language flexible array
2022-07-22 01:06:00 【East east!】
Catalog
One 、 Flexible array (flflexible array)
Two 、 The characteristics of flexible arrays :
3、 ... and 、 The use of flexible arrays
Four 、 The advantages of flexible arrays
One 、 Flexible array (flflexible array)
struct s
{
int num;
double d;
int arr[];// Flexible array members
};
perhaps Some compilers will report errors and cannot compile , Add one to the array 0
typedef struct st_type
{
int i;
int a[0];// Flexible array members
}type_a;
Two 、 The characteristics of flexible arrays :
typedef struct st_type
{
int i;
int a[0];// Flexible array members
}type_a;
printf("%d\n", sizeof(type_a));// The output is 4
struct s
{
int num;
double d;
int arr[];// Flexible array members
};
int main()
{
malloc(sizeof(struct s) + 40);
return 0;
}
3、 ... and 、 The use of flexible arrays
int i = 0;
type_a *p = (type_a*)malloc(sizeof(type_a)+100*sizeof(int));
// Business processing
p->i = 100;
for(i=0; i<100; i++) {
p->a[i] = i; }
free(p);
Four 、 The advantages of flexible arrays
First advantage :
边栏推荐
- If else: is there a clock cycle difference between the judgment statement and the execution statement? Parallel execution? Is there a priority?
- CUDA文件中无法打开源文件<stdio.h>
- HCIP 第二天作业 7.17
- dom——预加载和懒加载
- &lt;a&gt;标签跳转到Servelet页面并实现参数的传递
- [hcip continuous update] DHCP security threat
- Precautions for visual studio to reference external libraries
- HALCON和OPENCV最终选择了后者
- 记一次网站渗透的漏洞挖掘记录
- Time insertion syntax of Oracle table
猜你喜欢
[ar Foundation] ar Foundation Foundation Foundation Foundation
Number of columns in MySQL statistics table
攻防技术第一篇之-知彼(攻击手段)
Take C language from 0 to 1 - program structure and use examples
[AR Foundation] AR Foundation基礎
LeetCode刷题:二叉树层序遍历相关题目
Openshift security (17) - integrate compliance scanning of openshift compliance operator into rhacs
HCIA NAT实验报告 7.14
It turns out that it is so important in the construction of data center!
Is the Internet midlife crisis really that exaggerated when the same group of "elderly" employees are dismissed?
随机推荐
visual studio引用外部库的注意事项
TCP/IP协议栈Lwip的设计与实现:之七
DOM -- style operation
It turns out that it is so important in the construction of data center!
&lt;a&gt;标签跳转到Servelet页面并实现参数的传递
Web自动化处理“滑动验证码”
Basic process of generating files from scratch
Tokio channel performance test
温度信号测量K型热电偶信号采集器rs485/232远程IO转换模块
ES安装&ik中文解析器
探寻机器人创客教育中的趣味
International Accounting Standards IAS and IFRS
How PHP queries whether there are specified tables in MySQL database
Technology sharing | introduction to proxysql binlog reader component (Part 1)
Cloud native and low code platforms make agile enterprises
【RM_EE_Note】2 串口&遥控器
Redis 官方可视化工具,高颜值,功能真心强大!
【HCIP持续更新】DHCP安全威胁
Temperature signal measurement K-type thermocouple signal collector rs485/232 remote IO conversion module
How will Import SQL file into MySQL