I have been trying to use the first letter of the string for the Hash function i.e int hash = toupper(key[0]}-'A'; as suggested in the website study.cs50.net/hashtables.

But Iam getting this Clang Compiler Error dictionary.c:56:14: error: implicit declaration of function 'toupper' is invalid in C99 [-Werror,-Wimplicit-function-declaration] int hash=toupper(key[0]-'A'; Is there any otherway I can use ASCii values of the first letter that I can use as a Hashfunction? Uma1966

1 Answer 1


Let's assume that your question has several typos. It should read

int hash = toupper(key[0])-'A';

Having said that, did you remember to add the two necessary includes for toupper()?

#include <stdio.h>
#include <ctype.h>

If you forgot ctype.h, it will definitely produce the error that you said.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

  • The present problem is solved but there are other errors which I am unable to eliminate. I posted them in another question today,since they are driving me mad for a while. uma1966
    – uma1966
    Commented Dec 22, 2015 at 5:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .