Reputation: 689
This is causing a lot of issues for my program. Whys is it when I create a new array of structured pointers that they all equal to '\0'
? I checked if they are at the end of the array if(table_p -> buckets_array[i] == '\0'){ printf("ask this \n") ; }
and it is true for every member of the array. Am I checking it wrong? Shouldn't only the last member have \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");
}
}
Upvotes: 0
Views: 126
Reputation: 44250
if(table_p -> buckets_array[i] == '\0'){
I already pointed out in your previous (very similar) post, that table_p->buckets_array[i]
is of type "pointer to data_el", and that '\0' is an integer constant. Please read before you post.
Upvotes: 0
Reputation: 64308
In your code, you have:
table_p -> buckets_array[i] = NULL;
table_p -> buckets_array[i] -> buckets_size = 0;
That is like saying:
table_p -> buckets_array[i] = NULL;
NULL -> buckets_size = 0;
which is not good.
Upvotes: 2