I tried adding functionality to the djb2 hash function, but it doesn't appear to like the changes. Specifically, I'm trying to include a loop that converts words (strings) to lower case. It throws the following two errors:
- Incompatible integer to pointer conversion assigning to
char *fromint - Cannot increment value of type
char *[45]
Note that in the original code *str++ appeared in the while loop. This is my first hash table, and I'm rather shaky on pointers. Any insight on where I've gone wrong would be appreciated.
// djb2 by Dan Bernstein -- slightly modified;
unsigned int hash_function(const char* str)
{
unsigned int hash = 5381;
int c;
char* string[45];
for (int i = 0; str[i] != '\0'; i++)
{
string[i] = (tolower(str[i]));
}
while (c == *string++)
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
return (hash % LISTS);
}