空数组(伸缩型数组成员)
摘要:
#include <stdio.h>struct ast_var_t { struct ast_var_t *entries; char *value; char name[0];};int main(){ struct ast_var_t test; printf("size is %d\n", sizeof(test));return 0;}执行此程序我们可以看到:size is 8这是个广泛使用的常见技巧,常用来构成缓冲区。比起指针,用空数组有这样的优势: 1.不需要初始化,数组名直接就是所在的偏移 2.不占任何空间,指针需要占用int长度空间,空数组不占 阅读全文
posted @ 2013-05-07 17:01 keep_simple 阅读(512) 评论(0) 推荐(1)