我使用一個結構是這樣的:結構初始化問題?
define struct _Fragment{
int a;
char *seq;
}Fragment;
我想初始化結構,並使用的malloc()方法中返回這樣
Fragment *frag=malloc(10*sizeof(Fragment));
動態存儲器中。然後我會使用片段指針是這樣的:
frag->seq="01001";
然後,當我返回大量碎片時就會出現問題。錯誤消息說(使用valgrind工具):
Uninitialised value was created by a heap allocation
誰可以告訴我如何處理它。謝謝!
我認爲你的意思是「typedef struct ...」而不是「define struct ...」 – mhawke 2009-07-15 02:13:17