专注于互联网--专注于架构

最新标签
网站地图
文章索引
Rss订阅
C语言的偏方: 在C语言的世界里存在一个关于结构体的偏门技巧,例如: typedef struct _str_type { int _len; char _s[1]; }str_type; str_type用于保存字符串(我只是举例,事实上这个结构体没什么用处),乍看上去str_type只能保存长度为1的字符串('\0')。但是,通过写下如下的代码,你将突破这个限制: int str_len = 5; str_type *s = (str_type*) malloc( sizeof( str_type ) + str_len - 1 ); // free( [阅读全文] [PDF]
1 共1条 分1页