現在、C で adt のシミュレーションを行っています。文字列を含むバイナリ検索ツリーを作成することになっています。現在コーディングを開始していますが、このエラーが発生し、エラーの原因がわかりません。コードは次のとおりです。 、誰かが私を助けることができます。
ツリー.h
#ifndef tree_h
#define tree_h
#include <stdbool.h>
#include <stdlib.h>
typedef struct tree_node* node_ptr;
struct tree_node {
char* word;
node_ptr leftNode, rightNode;
};
node_ptr start = NULL;
void addItem(char*, int);
void display();
#endif
ツリー.c
#include "tree.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
void addItem(char arr[], int mode) {
node_ptr temp, temp2;
temp = (node_ptr)malloc(sizeof(struct tree_node));
temp->leftNode=NULL;
temp->rightNode=NULL;
if(mode == 1){
temp->word = arr;
start = temp;
}
}
void display() {
node_ptr temp;
temp = start;
printf("%s", start->word);
}
main.c
#include "tree.h"
#include <stdio.h>
#include <conio.h>
int main() {
char word[31];
printf("Enter Root Word: ");
gets(word);
addItem(word, 1);
}