Re: [問題] 如何一次給定struct以及內部指標記憶體?

看板C_and_CPP (C/C++)作者 (「雄辯是銀,沉默是金」)時間12年前 (2014/01/24 21:44), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/4 (看更多)
http://hi.baidu.com/drinkey/item/92b69645524c9ed3c1a5928c 你是要這樣的用法嗎? gcc 需使用 -std=c99 option gnu extension 也有類似功能 ref: http://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html ※ 引述《u8906250 (羊咩咩)》之銘言: : 開發平台(Platform): (Ex: VC++, GCC, Linux, ...) : GCC : 問題(Question): : 比如說有一個 struct : struct ggg { : int len; : void *data; : }; : 是否能在 malloc struct 的同時也 malloc data的大小1024 : 看起來像是 : struct ggg *g = malloc (sizeof(struct ggg)+1024) : 但沒辦法這樣做 : 請問是否能做呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 182.235.248.209 ※ 編輯: descent 來自: 182.235.248.209 (01/24 21:46)
文章代碼(AID): #1IucvNId (C_and_CPP)
文章代碼(AID): #1IucvNId (C_and_CPP)