Thread: HashTable in a struct

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    18

    HashTable in a struct

    Hi All,

    I keep getting these errors when I compile my hash table within a struct:

    error: syntax error before 'List'
    warning: no semicolon at end of struct or union
    This is the code of what I have done, hash.h contains all the required functions and when hashStruct is commented out it works fine.

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <stdbool.h>
    #include "hash.h"
    
    struct  hashStruct
    {
        List hashTable[MAXTABLE];
        int second variable;
    }
    typedef struct hashStruct test;
    
    int main()
    {
        test myHash;
        List hashTable[MAXTABLE];     // This works
        initialiseHash(myHash.hashTable);
        return 1;
    }
    I am able to declare the hash table in the same way without it being in a struct, any ideas whats wrong?

    A brief background, this hash table is part of a much larger program with a large struct that contains alot of useful information. I would prefer to just have the hash table accessible inside this struct then have to pass it around seperately.

    Thanks,
    Nick

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Whent it says "no semicolon at end of struct", that's pretty much what it means.
    Code:
    struct  hashStruct
    {
        List hashTable[MAXTABLE];
        int second variable;
    } <----- Where is your semicolon?
    It doesn't get much clearer than that.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with linked list sorting function
    By Jaggid1x in forum C Programming
    Replies: 6
    Last Post: 06-02-2009, 02:14 AM
  2. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  3. newbie needs help with code
    By compudude86 in forum C Programming
    Replies: 6
    Last Post: 07-23-2006, 08:54 PM
  4. Function validation.
    By Fhl in forum C Programming
    Replies: 10
    Last Post: 02-22-2006, 08:18 AM
  5. Search Engine - Binary Search Tree
    By Gecko2099 in forum C Programming
    Replies: 9
    Last Post: 04-17-2005, 02:56 PM