I am writing a program that works with hash tables using chaining. I have all my functions typed up but it keeps giving me the error:
error: conflicting types for (some function)
note: previous declaration of (some function) was here
It says this for all of my functions. I checked all function declarations in the header file and source file and I cant find any errors. Please help.
Here are the two header files:
List.h
Code:
/*
list.h: header file containing functions necessary to work with doubly linked lists
*/
/*
structure that contains variables necessary for a node in a linked list
*/
typedef struct LLnode
{
struct LLnode *next;
struct LLnode *prev;
int key;
} LLnode;
/*
structure that holds a list as a whole
*/
struct List
{
struct LLnode *head;
};
/*
listSearch searches through a linkd list for a certain key
input: a linked list and a key to be searching for
output: a pointer to a node
*/
LLnode* listSearch(struct List *L, int key);
/*
listInsert inserts a node at the head of a list
input: A linked list and a node to be inserted
ouput: none
*/
void listInsert(struct List *L, LLnode *x);
/*
listDelte deletes a node in a list
input: a linked list and a node to be deleted
output: none
*/
void listDelete(struct List *L, LLnode *x);
/*
createNode creates node with a string as its key
input: a string to be used as they key
output: a pointer to a node
*/
LLnode* createLNode(int key);
/*
freeLL is used for garbage collection when a node is deleted
input: a node to be freed
output: none
*/
void freeLL(LLnode *x);
/*
displayLL printsa linked list to the screen
input: a linked list
oupute: none
*/
void displayLL(struct List *L);
hash.h
Code:
/*
chain.h: header file containing functions necessary to work with hash tables
*/
#include "list.h"
struct Table
{
struct List table[100];
int value;
int size;
struct LLnode *node;
};
void chainHashInsert(struct Table *T, int k);
LLnode* chainHashSearch(struct Table *T, int k);
void chainHashDelete(struct Table *T, int k);
void multiplicationHash(struct Table *T, int k);
void divisionHash(struct Table *T, int k);
and here is the source file hash.c
Code:
#include "hash.h"
#include "list.h"
#include <stdlib.h>
#include <stdio.h>
void chainHashInsert(struct Table *T, int k)
{
divisionHash(&T, k);
T->node = createLNode(k);
listInsert(T->table[T->value], T->node);
}
LLnode* chainHashSearch(struct Table *T, int k)
{
divisionHash(&T, k);
T->node = listSearch(T->table[T->value], k);
return T->node;
}
void chainHashDelete(struct Table *T, int k)
{
divisionHash(&T, k);
T->node = listSearch(T->table[T->value], k);
if(T->node != NULL)
{
listDelete(T->table[T->value], T->node);
printf("\nValue deleted");
}
else
printf("\nThat value was not found");
}
void multiplicationHash(struct Table *T, int k)
{
int x;
x = 2;
}
void divisionHash(struct Table *T, int k)
{
T->value = k % (T->size);
}
I haven't implemented the multiplication hash yet but that's besides the point. Any help would be appreciated.