I'm trying to pass a pointer to a struct to a function and then return an edited version of said pointer. These are the declarations of the structs:
struct HshTble;
typedef struct HshTble *HashTable;
enum EntryStatus { Occupied, Empty, Deleted };
struct HashEntry {
int Element;
enum EntryStatus Info;
};
typedef struct HashEntry Entry;
struct HshTble{
int TableSize;
Entry *Array;
};
So as you can see there is a pointer to a struct within the other struct. My issue is when it comes to trying to do something with these things... I'll put my code so far, hopefully it's clear what's supposed to be happening but I'll add notes too.
void main(){
HashTable *table;
int size;
table = (HashTable*) malloc (sizeof(HashTable));
table = createTable(table, &size);
In this next bit is where the issues have risen, the idea is I want to edit the values inside table:
HashTable createTable(HashTable table, int *size){
int x, y, ch;
*size = 0;
fopen_s(&fp, DATA_FILENAME, "r");
while (EOF != fscanf_s(fp, DATA_FILENAME, &ch))
{
y = x = f(ch);
++*size;
if (table->Array[x].Info != Occupied)
{
table->Array[x].Element = ch;
table->Array[x].Info = Occupied;
}
else if (table->Array[x].Info == Occupied)
{
while (table->Array[y].Info == Occupied)
{
if (y > HASH_TABLE_SIZE)
{
y = 0;
table->Array[y].Element = ch;
table->Array[y].Info = Occupied;
}
else
{
table->Array[y + 1].Element = ch;
table->Array[y + 1].Info = Occupied;
}
y++;
}
}
return table;
}
}
It doesn't seem to like my function have the type of one of my structures among other things but I feel this is my main issue at the moment. Any help would be great.