Got the answer. Thanks Alexey but that wasn't really the problem. In the main function while printing i was trying to print the string stored in the hash table's index.
printf("%s %d\n",ht[key].str,key);
Instead I should be printing string at the location that the index points to (and not the index).
printf("%s %d\n",ht[key].next->str,key);