Re: [問題] 如何一次給定struct以及內部指標記憶體?
看板C_and_CPP (C/C++)作者descent (「雄辯是銀,沉默是金」)時間12年前 (2014/01/24 21:44)推噓0(0推 0噓 0→)留言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)
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 4 篇):
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章