質問編集履歴
1
プログラムを変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -169,3 +169,51 @@
|
|
169
169
|
asdffsa
|
170
170
|
|
171
171
|
Segmentation fault (コアダンプ)
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
```
|
176
|
+
|
177
|
+
struct t_node *add_tree(struct t_node *p,char *w){
|
178
|
+
|
179
|
+
int cond;
|
180
|
+
|
181
|
+
if(p==NULL){ この行を変更することによって解決
|
182
|
+
|
183
|
+
p=t_alloc();
|
184
|
+
|
185
|
+
p->substring=(char*)malloc(SUBLEN+1);
|
186
|
+
|
187
|
+
strcpy(p->substring,w);
|
188
|
+
|
189
|
+
p->count=1;
|
190
|
+
|
191
|
+
p->left=p->right=NULL;
|
192
|
+
|
193
|
+
}
|
194
|
+
|
195
|
+
else if((cond=strcmp(w,p->substring))==0){
|
196
|
+
|
197
|
+
p->count++;
|
198
|
+
|
199
|
+
}
|
200
|
+
|
201
|
+
else if(cond<0){
|
202
|
+
|
203
|
+
p->left=add_tree(p->left,w);
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
else{
|
208
|
+
|
209
|
+
p->right=add_tree(p->right,w);
|
210
|
+
|
211
|
+
}
|
212
|
+
|
213
|
+
return p;
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
```
|