这给我的程序带来了很多问题。为什么当我创建一个新的结构化指针数组时它们都等于'\0'
?我检查了它们是否位于数组的末尾,if(table_p -> buckets_array[i] == '\0'){ printf("ask this \n") ; }
并且对于数组的每个成员都是如此。我检查错了吗?不应该只有最后一个成员有\0
吗?
typedef struct data_{
char *key;
void *data;
struct data_ *next;
}data_el;
typedef struct hash_table_ {
void **order;
int *number_next_calls;
int *number_buckets;
int *buckets_size;
int *worst;
int *total;
float *average;
int (*hash_func)(char *);
int (*comp_func)(void*, void*);
data_el **buckets_array;
} hash_table, *Phash_table;
/*Create buckets array*/
table_p -> buckets_array = (data_el **)malloc(sizeof(data_el *)*(size+1));
table_p -> buckets_size = (int *)malloc(sizeof(int)*(size+1));
/*Setting order array*/
table_p -> order = NULL;
/*Setting inital condictions*/
table_p -> worst = (int *)malloc(sizeof(int));
table_p -> total = (int *)malloc(sizeof(int));
table_p -> average = (float *)malloc(sizeof(float));
table_p -> number_buckets = (int *)malloc(sizeof(int));
/*This is where I have isssue*/
for(i = 0; i < size; i++){
table_p -> buckets_array[i] = NULL;
table_p -> buckets_array[i] -> buckets_size = 0;
if(table_p -> buckets_array[i] == '\0'){
printf("ask this \n");
}
}