当前位置:网站首页>C语言 柔性数组
C语言 柔性数组
2022-07-21 05:39:00 【东区东区!】
目录
一、柔性数组(flflexible array)
struct s
{
int num;
double d;
int arr[];//柔性数组成员
};
或者有些编译器会报错无法编译,数组内加个0
typedef struct st_type
{
int i;
int a[0];//柔性数组成员
}type_a;
二、柔性数组的特点:
typedef struct st_type
{
int i;
int a[0];//柔性数组成员
}type_a;
printf("%d\n", sizeof(type_a));//输出的是4
struct s
{
int num;
double d;
int arr[];//柔性数组成员
};
int main()
{
malloc(sizeof(struct s) + 40);
return 0;
}
三、柔性数组的使用
int i = 0;
type_a *p = (type_a*)malloc(sizeof(type_a)+100*sizeof(int));
//业务处理
p->i = 100;
for(i=0; i<100; i++) {
p->a[i] = i; }
free(p);
四、柔性数组的优势
第一个优势:
边栏推荐
猜你喜欢
How to upload multiple pictures by applet
小程序实现图片上传
Download of typora and use of markdown
小程序 如何上传多张图片
一个程序员的水平能差到什么程度?
数据可视化第五章
如何将.sql文件导入到mysql中
H5 realize official account login
About a 500million data table, the battle between me and DBA
Machine learning K-means - nonzero (clusterassment[colon, 0].a==cent
随机推荐
h5 实现公众号登录
NAOMI代码详解
攻防技术第一篇之-知彼(攻击手段)
云原生与低代码平台成就敏捷企业
uniapp使用图表
Solve the problem of automatic completion of Spyder code
传统企业是否需要数据中台?
Applet access incentive video
小程序如何加入企业微信群聊
一个程序员的水平能差到什么程度?
SparkSQL 实验
自动引用计数与循环引用
Oracle VM VirtualBox NAT网络ping不通
A simple way to get headers and cookies
事件链、事件代理、页面的渲染过程、style的操作、防抖与节流【DOM(四)】
策略中心——企业建设数智运营平台的大脑
获取header和cookie的简易方法
Oracle设置最大连接数
1. Basic concepts of machine learning
数据可视化第四章答案