*简介

伸缩数组(flexible array)这是C99对结构体功能的扩展.可伸缩性的体现在于,在结构体的原型声明时,可以声明一个没有指定数组长度的数组,在使用时通过malloc动态决定结构体变量的数组大小.

*规则

---伸缩数据必须是结构体的最后一个成员

编译报错:"error: flexible array member not at end of struct"

---结构体至少还有一个其他成员

编译报错:"error: flexible array member in otherwise empty struct"

---伸缩数组的声明方式,形如char name[],即方括号没有内容

*示例

flexible_array.c

posted on 2011-06-06 01:14  戴忠  阅读(2024)  评论(1编辑  收藏  举报