The following is my current code. My professor told us to use a double pointer to create an array of pointers
struct dict {
struct word **tbl;
int (*hash_fcn)(struct word*);
void (*add_fcn)(struct word*);
void (*remove_fcn)(struct word*);
void (*toString_fcn)(struct word*);
};
struct word {
char *s;
struct word *next;
};
struct dict *hashtbl;
Part of the main function
hashtbl=malloc(sizeof(struct dict));
hashtbl->tbl=malloc(sizeof(struct word)*256);
int i;
for(i=0;i<256;i++)
{
hashtbl->tbl[i]=NULL;
}
is this the correct way to implement this sort of double pointer array?
and is using
hashtbl->tbl[i] = .....
the right way of accessing that space?
struct word **tbl?hashtbl->tbl=malloc(sizeof(struct word *)*256);