Hi, I am new to this board and rubbish at C so please be kind!
Im trying to initialise a hash table but am having trouble allocating memory for it. Can you please have a look and see where I've slipped up?
Code:
void Initialize(Table T)
{
int i,j;
T = calloc(TableSize,sizeof(TableEntry));
for (i=0;i<TableSize;i++)
{
T[i].Info.Actor = calloc(1, sizeof(TableSize));
T[i].Info.Films = calloc(1, sizeof(TableSize));
strcpy(T[i].Key,"XXX");
T[i].Info.NumberFilms=0;
strcpy(T[i].Info.Actor,"nnn");
for (j=0;j<50;j++)
{
T[i].Info.Films[j] = calloc(1, sizeof(TableSize));
strcpy(T[i].Info.Films[j],"hhh");
}
}
}
THe info structure is defined as
Code:
typedef struct
{
int NumberFilms;
char* Actor;
char** Films;
} InfoType;
And the table entry
Code:
typedef struct
{
KeyType Key;
InfoType Info;
} TableEntry;
typedef TableEntry Table[TableSize];
Thanks in advance
eeeeej