Can somebody please explain to me, why i am getting a seg fault when i call createhashtable from main function?
#include<stdio.h>
#include<stdlib.h>
typedef struct node* Node;
struct node
{
char* word;
Node next;
};
typedef struct htnode* ht;
struct htnode
{
int count;
ht head;
};
struct hashtable
{
int count;
int size;
ht* table;
};
struct hashtable* createhashtable(int size)
{
struct hashtable* h;
int i;
h = (struct hashtable*)malloc(sizeof(struct hashtable));
h->size = size;
h->count = 0;
h->table = (ht*)malloc((sizeof(struct htnode))*(h->size));
for(i=0;i<size;i++)
{
h->table[i]->count = 0;
h->table[i]->head = NULL;
}
return h;
}