Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

[C]Operators, structs and arrays hlp[Complex]

Name: VIPPER 2011-02-16 12:08

Hi /prog/.
I know /prog/ does not like help threads but this one is a ballbuster(atleast for me).
Anyways, i have a struct that looks like this:

struct hash_entry {
  sdr he_Data, he_Symbol;
};

struct hash_index {
  u32 hi_Hash, hi_NumEntries;
  struct hash_entry **hi_Entries;
};

struct hash_table {
  u32 ht_NumEntries;
  struct hash_index ht_Indeces[];
};
or this if you prefer.
struct hash_table {
  u32 ht_NumEntries;
  struct {
    u32 hi_Hash, hi_NumEntries;
    struct {
      sdr he_Data, he_Symbol;
    } (*hi_Entries)[];
  } ht_Indeces[];
};

Now i dont know how to assign something to the hi_Entries[x]->he_Data or he_Symbol.
I looked up K&R and the Cbook but all i got was this: ((struct hash_entry*)(*FX->ht_Indeces[0].hi_Entries)[0])->he_Symbol = Key; but GCC gives cannot convert to a pointer type

I think you can guess what i want to do looking from the code.

Name: VIPPER 2011-02-16 12:21

Sorry, forgot to change some stuff in my post.
[m]FX is declared as: [code] struct hash_table *FX = some_allocated_memory;

typedef unsigned int u32;
typedef unsigned char* sdr;[code]
And the first hash_table is commented out and [m]**hi_Entries[/m] should be [m](*hi_Entries)[]


And i meant to say you can guess what the struct is for, i just cannot access it.

PS: i know a better way of doing this, please tell.

Name: Anonymous 2011-02-16 12:51

>>1
what the fuck are you trying to do?

Name: VIPPER 2011-02-16 13:02

>>3
I try to make a hashtable and functions associated(put, get, delete etc).

Whereby the values are stored somewhere in memory and only references to them are kept in the table it self
struct hash_table is the table itself.
struct hash_index is a container for a hash calculated using a symbol and and has a pointer to an array of struct hash_entry and count of said structs. Inside the struct hash_entry a pointer to the data is stored and references to symbols if the hash for two different symbols happens to be the same.

Name: Anonymous 2011-02-16 15:54

>>1

fuck you faggot

Name: Anonymous 2011-02-16 18:38

paste your code on codepad and go find help in /halp/

Name: Anonymous 2011-02-16 22:25

typedef unsigned char* sdr;
My other char is a cheddar.

Don't change these.
Name: Email:
Entire Thread Thread List