推 cgcheng:list在c++現成可用,c的話好像要先malloc? 61.229.216.62 08/27 00:50
→ cgcheng:程式要不要先列出來一下? 61.229.216.62 08/27 00:52
→ cgcheng:也可以用valgrind測試一下 61.229.216.62 08/27 01:07
推 SmallBeeWayn:有沒有可能是初值問題?122.116.180.163 08/27 01:45
→ cgcheng:看有沒有core file之類的,backtrace 61.229.234.235 08/29 13:48
t1.root=new TreeNode;
strcpy(t1.root->data,clause);
q1=&(t1.root->children);
q1=&那行似乎有問題
這樣寫有什麼問題嗎
謝謝各位
struct childchain
{
TreeNode* child;
childchain* next;
};
class TreeNode
{
friend class Tree;
public:
childchain children;
int vocabnum;
char *data;
};
※ 編輯: ok456 來自: 61.62.94.142 (08/29 19:08)
→ james732:你的q1是什麼型態? 140.117.171.46 08/29 20:36
→ ok456:childchain* 61.62.94.142 08/29 21:17
→ loveme00835:t1.root->data 有沒有配置空間? 沒配140.121.197.115 08/29 21:41
→ loveme00835:用strcpy一定炸140.121.197.115 08/29 21:41
→ ok456:阿= =new TreeNode還不夠對吧? 61.62.94.142 08/29 22:03
→ ok456:還要讓data去new是嗎? 61.62.94.142 08/29 22:03
→ loveme00835:當然阿= =140.121.197.115 08/29 22:06
→ ok456:非常感謝 61.62.94.142 08/29 22:08
→ darkgerm:如果寫char data[100];是不是就不用new了 124.8.140.3 08/29 22:08
→ loveme00835:是阿, 只不過這樣節點佔的空間會很大140.121.197.115 08/29 22:13