I am using the SDBM hash function in a program and have a question regarding the function definition, reproduced below:
static unsigned long
sdbm(str)
unsigned char *str;
{
unsigned long hash = 0;
int c;
while (c = *str++)
hash = c + (hash << 6) + (hash << 16) - hash;
return hash;
}
I understand by trial and error that the function is expecting an unsigned char *
, but why place it after the brackets and before the curly brace? I didn't know this was an option, and I can't find anything to tell me why it's not written like this instead:
static unsigned long
sdbm(unsigned char *str)
{
....
}
Of course, if I do modify it to be like this, the function still appears to work perfectly well, so why do it? What's the difference?