Thread: Hash table

  1. #1
    Unregistered
    Guest

    Question Hash table

    Hi,

    Does anyone know how to display contents of a hash table?

    Thanks

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    7
    hi ,
    i don't know exactly how you mean it ,
    but maybe
    struct nlist *lookup(char *s)
    {
    struct nlist *np;
    for(np=hashtab[hash(s)]; np != NULL; np = np->next)
    if (strcmp(s, np->name) == 0 )
    return np; /*found*/
    return NULL;/*not found*/
    }

  3. #3
    Now if I'm not mistaken (and if I remember correctly, as it has been a while since I've had to use hash tables), a hash table is nothing more than a souped up array.

    So in order to display the contents you would basically treat it as if you are printing out the contents of an array (i.e. for an array w/10 spaces, print 0 - 9). You may hit some problems if your hash table had some collisions. If this is the case, it would depend on how you handled the collisions.

    I'll look through my program to see if I can find any hash talbes...
    Last edited by DrakkenKorin; 01-14-2002 at 07:01 PM.
    DrakkenKorin

    Get off my Intarweb!!!!

  4. #4
    Found the project I had to use a hash table in. Feel free to look at it. If you have any questions, feel free to ask and I'll see if I can remember enough to answer them.
    DrakkenKorin

    Get off my Intarweb!!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dictionary in C# to hash table in C?
    By dinoman in forum C Programming
    Replies: 2
    Last Post: 04-12-2009, 09:23 PM
  2. Writing array, to file
    By zootreeves in forum C Programming
    Replies: 9
    Last Post: 09-08-2007, 05:06 PM
  3. Group Project Help/Volunteer
    By DarkDot in forum C++ Programming
    Replies: 3
    Last Post: 04-24-2007, 11:36 PM
  4. Hash table creation and insertion
    By tgshah in forum C Programming
    Replies: 1
    Last Post: 01-23-2006, 07:54 PM
  5. Not sure on hash table memory allocations
    By Thumper333 in forum C Programming
    Replies: 3
    Last Post: 09-27-2004, 09:00 PM