0
私はエラーを取得しておく:コマンドを使用して、私のハッシュテーブルのADTをコンパイルしようとしたときは、ハッシュテーブルADTをコンパイルすることはできません - C
- 割り当ては、キャスト
なしポインタから整数を作る:
gcc hash_NEW.c -c
1つの関数で大きな.cファイルにエラーが発生しました。事前に助けを おかげ
エラー1行にここに起こる(インデックス=卓上> hash_func;)ヘッダファイルの
void insert_hash(Phash_table table, char *key, void *data){
Phash_entry new; //pointer to a new node of type hash_entry
int index;
new = (Phash_entry)malloc(sizeof(hash_entry));
new->key = (char *)malloc(sizeof(char)*strlen(key)); //creates the key array based on the length of the string-based key
new->data = data; //stores the user's data into the node
strcpy(new->key,key); //copies the key into the node
//calling the hash function in the user's program
index = table->hash_func; //index will hold the hash table value for where the new
table->buckets[index] = new; //Assigns the pointer at the index value to the new node
table->total++; //increment the total (total # of buckets)
}
部:型定義を見てみると
typedef struct hash_table_ {
hash_entry **buckets; //Pointer to a pointer to a Linked List of type hash_entry
int (*hash_func)(char *);
int (*cmp_func)(void *, void *);
int size;
void **sorted_array; //Array used to sort each hash entry
int index;//=0
int total; //=0
int sort_num; //=0
} hash_table, *Phash_table;
ええ私はそれを投稿した直後に2番目のものを見つけました。私はその構造体に関連するヘッダファイルの部分を追加しました。あなたが提供したコードは確かに訂正です。そのようにして、私はkeyの引数でユーザーのハッシュ関数を呼び出します。したがって、正しいインデックス値を取得し直してください。ああ、意味がある!早速のご返事ありがとうございます!! –
今、それはコンパイルされます!素晴らしい、私は十分にあなたに感謝しない、私はこれを見て新鮮な目が必要 –
yw。 'strcpy(new-> key、key);行を見てください。あなたは苦労するつもりです。 –