Hello,
I am trying to write a program that simulates a hash table using chaining to prevent collision. I'm still kind of weak on linked lists so I am having trouble trying to work with an array of linked lists. The problem I am having is that if the index value that the hash function produces is a repetition then i need to add a node to the linked list in that array element. Code compiles but output is incorrect, can anybody tell me what I am doing wrong.
Thanks
Code:
while((fscanf(finp, "%s", string))!= EOF)
    {
      i = hash_function_one (string, size);

      if(curr[i]->string == NULL)
        {
          curr[i] = (list*)malloc(sizeof(list));
          strcpy(curr[i]->string, string);
        }
      if(curr[i]->string != NULL)
        {
          curr[i] = (list*)malloc(sizeof(list));
          strcpy(curr[i]->string, string);
          curr[i]->next = head;
          head = curr[i];
        }
    }