typedef struct hashtable
{
char str[15];
struct hashtable *next;
}htable;
int hashkey(char *str)
{
//correctly returns hash key
}
int hash(htable * ht, char str[15], int key)
{
//error checking done
if(ht[key].next==NULL)
{
htable * temp = (htable *)malloc(sizeof(ht));
strncpy(temp->str, str,15);
temp->next = NULL;
//printf("%s %d\n",temp->str,key);
ht[key].next = temp;
//printf("%s %d\n",ht[key].next->str,key);
return 1;
}
}
void main()
{
int cnt=0,key;
FILE *fp = fopen("Keywords.txt","r");
if(fp==NULL)
{
printf("Error\n");
return;
}
while(fgetc(fp)!=EOF)
cnt++;
htable ht[cnt];
char aa[15];
rewind(fp);
while(fgets(aa,15,fp))
{
key=hashkey(aa);
if(hash(ht,aa,key))
{
printf("%s %d\n",ht[key].str,key);
}
}
}
typedef struct hashtable
{
char str[15];