I've posted on this one before and got advice that has got me to almost finish this pset (thanks, blauelf!), but now I'm totally stuck. Everything seems to work except for I can't get the word from the text to lower case to check for the hash value and compare with the dict word. I know it has to be converted before the hash function or the ASCII values are different and it doesn't go to the right 'bucket' if there are any uppercase letters. But I'm still struggling with the function I've written to get the word to lowercase - I get the error "incompatible integer to pointer conversion assigning to 'const char *' from 'char'". I just can't work out which bit is causing the problem - as far as I can see all the vars are const char *'s so where is the 'char'? The code is here: http://pastebin.com/Yd3h3Fqe Thankyou! Cally
word = strcicmp(word); doesn't compile because
word is a
const char* and
strcicmp returns a
const char.1 You can't do this
word = strcicmp(word); anyway because
word is a const and as such cannot be changed.
A serious problem with the
strcicmp function: It
returns after it processes the first letter in the string.
The dilemma is:
word is a const therefore cannot be changed. But it needs to be "changed" into lower case for the hash function. What to do? One option would be to declare and allocate a new string, copy word into it (letter-by-letter transforming to lower case as you go), and send the lower-case word to hash. [You can send a
char * to a function that declares it's argument as
const char *, because a const function argument will accept a type that is "less strict".] You could do it in a function or in-line in the check routine. Don't forget to properly allocate and null terminate any string you create. You could use the lower-case word for comparing, too (or
1Don't you also get a compile error that
'const' type qualifier on return type has no effect? If not, maybe you are not on the current IDE version (98 as of this writing) and update50 is in order.