typedef struct hash_table_data
{
int key;
int data;
struct hash_table_data* next;
struct hash_table_data* prev;
}hash_table_data;
typedef struct hash_table
{
int num_entries;
struct hash_table **entries;
}hash_table;
VERSUS
struct hash_table_data_
{
int key,data;
struct hash_table_data_ *next,*prev;
};
typedef struct hash_table_data_ hash_table_data;
struct hash_table_
{
int num_entries;
struct hash_table_data_ **entries;
};
typedef struct hash_table_ hash_table;
In the second example, you have an extra names in action:
struct hash_table_data_andstruct hash_table_In the first example, you effectively hide the name
struct hash_table_datawith a typedef which renamesstruct hash_table_datato the shorterhash_table_data.Think of it like so:
vs
Now in the latter example, you actually don’t do exactly what the former example does. In the latter example, you do
The key here is that you have an “extra” struct X_ which could be used directly.