我在将结构中的指针设置为 NULL 时遇到了一些问题。我遇到了分段错误。是什么原因造成的,我该如何解决?
typedef struct data_{
void *data;
struct data_ *next;
}data_el;
typedef struct buckets_{
char *key;
data_el *head_data_p;
}buckets;
typedef struct hash_table_ {
/* structure definition goes here */
int (*hash_func)(char *);
int (*comp_func)(void*, void*);
buckets **buckets_array;
} hash_table, *Phash_table;
int i,size;
size = 10;
table_p -> buckets_array = (buckets **)malloc(sizeof(buckets)*(size+1));
for(i = 0; i < size; i++){
/*Getting segmitation falut here*/
table_p -> buckets_array[i] -> key = NULL;
table_p -> buckets_array[i] -> head_data_p = NULL;